1,112,,ASIF
下面的代码消除了连续两个逗号之间的空值。提供 代码超过则需要
String p1=null, p2=null;
while ((lineData = Buffreadr.readLine()) != null)
{
row = new Vector(); int i=0;
StringTokenizer st = new StringTokenizer(lineData, ",");
while(st.hasMoreTokens())
{
row.addElement(st.nextElement());
if (row.get(i).toString().startsWith("\"")==true)
{
while(row.get(i).toString().endsWith("\"")==false)
{
p1= row.get(i).toString();
p2= st.nextElement().toString();
row.set(i,p1+", "+p2);
}
String CellValue= row.get(i).toString();
CellValue= CellValue.substring(1, CellValue.length() - 1);
row.set(i,CellValue);
//System.out.println(" Final Cell Value : "+row.get(i).toString());
}
eror=row.get(i).toString();
try
{
eror=eror.replace('\'',' ');
eror=eror.replace('[' , ' ');
eror=eror.replace(']' , ' ');
//System.out.println("Error "+ eror);
row.remove(i);
row.insertElementAt(eror, i);
}
catch (Exception e)
{
System.out.println("Error exception "+ eror);
}
//}
i++;
}
如何读取从Java中的.csv文件格式的独特价值连续两个逗号。
+0
你是什么意思通过在Java读独特的价值? –
+0
由唯一我的意思是单独或现有的价值观,当在excel中打开csv文件时显示为空单元格的值 –
+0
@Anugoonj:非常感谢,您提供的信息无疑是有帮助的。但我已在旧版软件中进行更改.. –