возникает есключение IOException в чем причина никак не пойму, это исключение возникает при записи объекта т.е. в строке output.writeObject(saveObject);
public class Solution {
public static void main(String[] args) {
System.out.println(new Solution(4));
Solution saveObject = new Solution(-8);
Solution loadObject;
ObjectOutputStream output;
ObjectInputStream input;
try{
System.out.println(saveObject.toString());
output = new ObjectOutputStream(new FileOutputStream("test"));
output.writeObject(saveObject);
output.close();
input = new ObjectInputStream(new FileInputStream("test"));
loadObject = (Solution)input.readObject();
input.close();
}catch (FileNotFoundException e){
System.out.println("File not found");
e.printStackTrace();
}
catch (IOException e){
System.out.println("error IO");
e.printStackTrace();
}
catch (ClassNotFoundException e){
System.out.println("Class not found");
e.printStackTrace();
}
}
transient private final String pattern = "dd MMMM yyyy, EEEE";//константа
transient private Date currentDate;//создается новая дата при создании объекта
transient private int temperature;//в водится из потока
String string;
public Solution(int temperature) {
this.currentDate = new Date();
this.temperature = temperature;
string = "Today is %s, and the current temperature is %s C";
SimpleDateFormat format = new SimpleDateFormat(pattern);
this.string = String.format(string, format.format(currentDate), temperature);
}
@Override
public String toString() {
return this.string;
}
}