私は別のファイルをコピーしましたが、次のコードを使用して2番目のファイルに同じテキストが含まれているので、私のファイル(特に2行目)から行を削除します。私の最終的なファイルの.xml)ファイルの位置を知ってファイルから行を削除するには?
public static File fileparse() throws SQLException, FileNotFoundException, IOException {
File f=fillfile();//my original file
dostemp = new DataOutputStream(new FileOutputStream(filetemp));
int lineremove=1;
while (f.length()!=0) {
if (lineremove<2) {
read = in.readLine();
dostemp.writeBytes(read);
lineremove++;
}
if (lineremove==2) {
lineremove++;
}
if (lineremove>2) {
read = in.readLine();
dostemp.writeBytes(read);
}
}
return filetemp;
}
2番目の後に何が起こるかを考えてください。それは本当にあなたが望むものですか? – Jacob