public static void ReadWorkingList() { DataInputStream inputStream = new DataInputStream(new FileInputStream("E:\\Working")); while (inputStream.available() > 0) { System.out.println(inputStream.readUTF()); } } public static void WorkingDelete() throws Exception { BufferedReader read = new BufferedReader(new InputStreamReader(System.in)); DataInputStream in = new DataInputStream(new FileInputStream("E:\\Working")); DataOutputStream outWrite = new DataOutputStream(new FileOutputStream("E:\\tmp")); while (in.available()>0) { System.out.println(in.readUTF()); } System.out.println("Введите имя человека, которого нужно удалить"); String deleteName = read.readLine(); while (in.available()>0) { String tmp = in.readUTF(); if(tmp.equals(deleteName))//сравнение введённого имени со строками в файле, если есть такое, то след.итерация. { continue; } outWrite.writeUTF(tmp); } //запись из файла TMP в файл DataInputStream outTMPinWorkList = new DataInputStream(new FileInputStream("E:\\tmp")); DataOutputStream WriteList = new DataOutputStream(new FileOutputStream("E:\\Working")); while (outTMPinWorkList.available()>0) { WriteList.writeChars(outTMPinWorkList.readUTF()); // Запись из одного файла в другой } outTMPinWorkList.close(); WriteList.close(); read.close(); in.close(); outWrite.close(); }
Tell me why EOFEexception crashes? Why he does not have time to count? And why doesn't WorkingDelete write to the tmp file? Help me please
outWrite.close()
). - zRrr 6:49 pmwriteChars
not written in the format that expectsreadUTF
, after the first start the program writes toE:\Working
content that it cannot read. - zRrr