이와 같은 문제를 해결하기위해서는 파일정보를 해석하는 부분의 코드와, 기본 인코딩을 조정해 주면 된다.
commons-net의 소소코드는 다음 svn 주소에서 내려받을 수 있다.
http://svn.apache.org/repos/asf/commons/proper/net/trunk
수정이 필요한 파일은 다음과 같다.
/commons-net/src/main/java/org/apache/commons/net/ftp/FTPFileEntryParser.java
수정전
private static final String REGEX =
"([bcdelfmpSs-])"
+"(((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-])))\\+?\\s*"
+ "(\\d+)\\s+" // link count
+ "(?:(\\S+(?:\\s\\S+)*?)\\s+)?" // owner name (optional spaces)
+ "(?:(\\S+(?:\\s\\S+)*)\\s+)?" // group name (optional spaces)
+ "(\\d+(?:,\\s*\\d+)?)\\s+" // size or n,m
/*
* numeric or standard format date:
* yyyy-mm-dd (expecting hh:mm to follow)
* MMM [d]d
* [d]d MMM
* N.B. use non-space for MMM to allow for languages such as German which use
* diacritics (e.g. umlaut) in some abbreviations.
*/
+ "((?:\\d+[-/]\\d+[-/]\\d+)|(?:\\S{3}\\s+\\d{1,2})|(?:\\d{1,2}\\s+\\S{3}))\\s+"
/*
year (for non-recent standard format) - yyyy
or time (for numeric or recent standard format) [h]h:mm
*/
+ "(\\d+(?::\\d+)?)\\s+"
+ "(\\S*)(\\s*.*)"; // the rest
수정후
private static final String REGEX =
"([bcdelfmpSs-])"
+"(((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-])))\\+?\\s*"
+ "(\\d+)\\s+" // link count
+ "(?:(\\S+(?:\\s\\S+)*?)\\s+)?" // owner name (optional spaces)
+ "(?:(\\S+(?:\\s\\S+)*)\\s+)?" // group name (optional spaces)
+ "(\\d+(?:,\\s*\\d+)?)\\s+" // size or n,m
/*
* numeric or standard format date:
* yyyy-mm-dd (expecting hh:mm to follow)
* MMM [d]d
* [d]d MMM
* N.B. use non-space for MMM to allow for languages such as German which use
* diacritics (e.g. umlaut) in some abbreviations.
*/
+ "("
+ "(?:\\d+\\S*\\s+\\d+\\S+)|"
+ "(?:\\d+[-/]\\d+[-/]\\d+)|(?:\\S{3}\\s+\\d{1,2})|(?:\\d{1,2}\\s+\\S{3}))\\s+"
/*
year (for non-recent standard format) - yyyy
or time (for numeric or recent standard format) [h]h:mm
*/
+ "(\\d+(?::\\d+)?)\\s+"
+ "(\\S*)(\\s*.*)"; // the rest
/commons-net/src/main/java/org/apache/commons/net/ftp/FTP.java
수정전
public static final String DEFAULT_CONTROL_ENCODING = "ISO-8859-1";
수정후
public static final String DEFAULT_CONTROL_ENCODING = System.getProperty("file.encoding");
소스코드의 수정이 끝났으면 다음과 같이 maven을 이용하여 jar 파일을 생성한다.
mvn clean package -DskipTests