Программисты JAVA общаются здесь
-
Anonymous
Java.io.EOFException при чтении объекта из файла ByteStream
Сообщение
Anonymous »
Код: Выделить всё
import java.io.*;
class DeSerialization {
public static void main(String[] args) {
String filename = "D:\\Tempo\\myFile.txt";
try {
FileInputStream fileInputStream = new FileInputStream(filename);
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
SeriExample ExD = (SeriExample)objectInputStream.readObject();
System.out.println(ExD.name);
System.out.println(ExD.number);
objectInputStream.close();
fileInputStream.close();
}
catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
System.out.println("An Error occurred");
}
}
}
Нет ошибок. При компиляции отображается, но запустить невозможно.
В чем проблема??
Подробнее здесь:
https://stackoverflow.com/questions/793 ... tream-file
1736942216
Anonymous
[code]import java.io.*;
class DeSerialization {
public static void main(String[] args) {
String filename = "D:\\Tempo\\myFile.txt";
try {
FileInputStream fileInputStream = new FileInputStream(filename);
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
SeriExample ExD = (SeriExample)objectInputStream.readObject();
System.out.println(ExD.name);
System.out.println(ExD.number);
objectInputStream.close();
fileInputStream.close();
}
catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
System.out.println("An Error occurred");
}
}
}
[/code]
Нет ошибок. При компиляции отображается, но запустить невозможно.
В чем проблема??
Подробнее здесь: [url]https://stackoverflow.com/questions/79358098/java-io-eofexception-while-reading-object-from-a-bytestream-file[/url]