- 日志
- 好友
- 卖家信用
- 买家信用
- 注册时间
- 2010-7-6
- 在线时间
- 小时
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册账号
x
public void put(String s,boolean b) {
if (pw == null) {
throw new IllegalArgumentException(
"attempt to use a closed CSVWriter");
}
if (s == null) {
nl();
return;
}
if (wasPreviousField) {
pw.print(separator);
}
if (trim) {
s = s.trim();
}
if (s.indexOf(quote) >= 0) {
/* worst case, needs surrounding quotes and internal quotes doubled */
pw.print(quote);
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == quote) {
pw.print(quote);
pw.print(quote);
} else {
pw.print(c);
}
}
pw.print(quote);
} else if (b) {
/* need surrounding quotes */
pw.print(quote);
pw.print(s);
pw.print(quote);
} else {
if (quoteLevel == 2 || (quoteLevel == 1
&& s.indexOf(' ') >= 0) || s.indexOf(separator) >= 0
|| s.indexOf("\n") >= 0 || s.indexOf("\r\n") >= 0) {
/* need surrounding quotes */
pw.print(quote);
pw.print(s);
pw.print(quote);
} else {
/* ordinary case, no surrounding quotes needed */
pw.print(s);
}
}
/* make a note to print trailing comma later */
wasPreviousField = true;
}
public void put(String s) {
put(s,true);
}
/**
* Write a new line in the CVS output file to demark the end of record.
*/
public void nl() {
if (pw == null) {
throw new IllegalArgumentException(
"attempt to use a closed CSVSWriter");
}
/* don't bother to write last pending comma on the line */
pw.print("\r\n"); /*
* windows conventions since this is a windows
* format file
*/
wasPreviousField = false;
}
value=value+ temp + "\r\n";
value = StringUtils.replace(value, "\r", "");
value = StringUtils.replace(value, "\n", "");
value = StringUtils.convertSpectial(value);
csvWriter3.put(value);
csvWriter1.nl();
|
-
-
cvs.rar
2.51 KB, 下载次数: 3, 下载积分: 元气 -1 点
|