0

(对不起我的拼写错误)输出来自 .cvs 文件

"First Name","Last Name","Main-Email","Current Employer","Internal Contact ID","PSI Club Member Nbr.","Membership Type","Membership Status","Member since", "会员卡发送","会员开始日期","会员到期日期","国籍 1","会员 ID" "Pierre","ABT","piero.a@bluewin.ch",,"1655", "1350","居民更新","Active","1968-01-01","2011 年 2 月 10 日","1968-01-01","1968-12-31",,"1915" "Bruno ","ADAM","bruno.adam@bluewin.ch","OCTAVE GROUP","1656","5288","居民更新","Active","2012-01-01","2012 年 2 月 16 日","2012-01-01","2012-12-31","法国","424

i want output in this way..separate line between each data.How to do frnds..


 here is my code can any guide me..thanks in advance.
"Bruce", |"ADAMS", |"bruce.adams@bluewin.ch",|,"1657",|"883",|"Resident  Renewal",|"Active",|"2011-05-10",|,"2012-01-01",|"2012-12-31",|"Canada",
         |         |                         |               |                   | 
         |         |                         |               |                   |



import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.StringTokenizer;

public class FileRead {
/**
* @param args
*/
public static void main(String[] args) {
String fileName="C:/Users/Desktop/cvsFile.csv";
try {
BufferedReader br = new BufferedReader( new FileReader(fileName));
String strLine = null;
StringTokenizer st = null;
int lineNumber = 0, tokenNumber = 0;
while( (fileName = br.readLine()) != null)
{
lineNumber++;

  /* String[] result = fileName.split("[\r\n]+");
for (int x=0; x<result.length; x++) {
    System.out.println(result[x]);*/


//break comma separated line using ","
st = new StringTokenizer(fileName, "|");
while(st.hasMoreTokens())
{
//display csv values
tokenNumber++;
System.out.println("Line # " + lineNumber + " Token : "+ st.nextToken());
}
//reset token number
tokenNumber = 0;
}
 //  }
}
catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

在此处输入图像描述

是否有任何选项可以在 java 中执行上述图像输出。
我想要 d 以这种方式输出。任何人都可以指导我..上面有一个代码...在中间我需要分隔输出数据的行。提前致谢..

4

1 回答 1

1

为什么不用新的分隔符替换逗号,例如:

str.replace(",", ",|,");
于 2012-09-03T06:11:38.160 回答