C:\SystemUser\UniEAP V3.3.0\workspace\zzbx\EAPDomain\WEB-INF\lib
以上路径解析后,会变成:C:SystemUserUniEAP V3.3.0workspacezzbxEAPDomainWEB-INFlib,远非我们所要的结果。
处理方式:重构openCSV.jar里的CSVReader文件 readNext()方法,如下
/**
* 重构,支持解析'\'
* @return
* @throws IOException
* @author backkom
*/
public String[] readNext() throws IOException {
String[] localObject = null;
do {
String str = getNextLine();
if(str != null){
str = str.replace("\\", "\\\\");//添加此段代码
}
if (!this.hasNext)
return localObject;
String[] arrayOfString1 = this.parser.parseLineMulti(str);
if (arrayOfString1.length <= 0)
continue;
if (localObject == null) {
localObject = arrayOfString1;
} else {
String[] arrayOfString2 = new String[localObject.length
+ arrayOfString1.length];
System.arraycopy(localObject, 0, arrayOfString2, 0,
localObject.length);
System.arraycopy(arrayOfString1, 0, arrayOfString2,
localObject.length, arrayOfString1.length);
localObject = arrayOfString2;
}
} while (this.parser.isPending());
return localObject;
}
手机扫一扫,欢迎关注公众号
关注程序员成长