日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java删除csv一行_在Java中读取CSV文件时跳过第一行

發布時間:2025/3/8 java 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java删除csv一行_在Java中读取CSV文件时跳过第一行 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

嘿家伙我正在編寫解析器代碼來讀取.csv文件并將其解析為

XML.這是我的代碼,它工作正常,但我希望它跳過文件中的第一行.所以我決定設置一個HashMap,但它似乎確實有效:

for (int i = 0; i < listOfFiles.length; i++) {

File file = listOfFiles[i];

if (file.isFile() && file.getName().endsWith(".csv")){

System.out.println("File Found: " + file.getName());//Prints the name of the csv file found

String filePath = sourcepath + "\\" + file.getName();

BufferedReader br = new BufferedReader(new FileReader(file));

String line;

int n = 1;

Map lineMap = new HashMap();

int k=2;

while ((line = br.readLine()) != null) {

System.out.println(n + " iteration(s) of 1st While Loop");

lineMap.put(k, line);

fw.write(" \n");

fw.write(" \n");

hostName=line.substring(0, line.indexOf(","));

fw.append(hostName);

fw.write("\n");

fw.write(" \n");

hostID=line.substring(line.indexOf(",")+1, nthOccurrence(line, ',', 1));

fw.append(hostID);

fw.write("\n");

fw.write(" \n");

machineModel=line.substring(nthOccurrence(line, ',', 1)+1, nthOccurrence(line, ',', 2));

fw.append(machineModel);

fw.write("\n");

fw.write(" \n");

processorModel=line.substring(nthOccurrence(line, ',', 2)+1, nthOccurrence(line, ',', 3));

fw.append(processorModel);

fw.write("\n");

fw.write(" \n");

core=line.substring(nthOccurrence(line, ',', 3)+1, nthOccurrence(line, ',', 4));

fw.append(core);

fw.write("\n");

fw.write(" \n");

proc=line.substring(nthOccurrence(line, ',', 4)+1, nthOccurrence(line, ',', 5));

fw.append(proc);

fw.write("\n");

fw.write(" \n");

tier=line.substring(nthOccurrence(line, ',', 5)+1, nthOccurrence(line, ',', 6));

fw.append(tier);

fw.write("\n");

fw.write(" \n");

productName=line.substring(nthOccurrence(line, ',', 6)+1, nthOccurrence(line, ',', 7));

fw.append(productName);

fw.write("\n");

fw.write(" \n");

version=line.substring(nthOccurrence(line, ',', 7)+1, nthOccurrence(line, ',', 8));

fw.append(version);

fw.write("\n");

fw.write(" \n");

scriptData=line.substring(nthOccurrence(line, ',', 8)+1, line.length());

fw.append(scriptData);

fw.write("\n");

fw.write(" \n");

k++;

}n++;

這是代碼主要部分的片段.任何想法或解決方案???

總結

以上是生活随笔為你收集整理的java删除csv一行_在Java中读取CSV文件时跳过第一行的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。