objectoutputstream exemple
public static void main(String[] args) throws IOException, ClassNotFoundException {
Obj array[] = new Obj[10];
for (int i = 0; i < array.length; i++) {
array[i] = new Emp(i);
}
try {
ObjectOutputStream fOUT = new ObjectOutputStream(new FileOutputStream("prodotti.dat"));
for (int i = 0; i < array.length; i++) {
fOUT.writeObject(array[i]);
}
fOUT.close();
} catch (IOException e) {
System.out.println("Errore nella scrittura");
}
ObjectInputStream fIN = new ObjectInputStream(new FileInputStream("prodotti.dat"));
while (true) {
try {
Obj p = (Obj) fIN.readObject();
System.out.println(Obj.method());
} catch (EOFException e) {
break;
}
}
}
Also in Java:
- get value textfield java
- java print type of object
- string contains java
- how to do for each in java
- determine if a given binary tree is a valid bst
- fibonacci sequence in java recursion
- Enums injava
- java get current date without time
- java get folder content
- how to play a clip of audio in java when needed
- guess the number java
- how to install java runtime environment on centos 7
- java how to program
- java replace element in list
- java swing button on click
- JFrame text java
- java tester si un caractere est une lettre
- classes in java
- java create file
- connecting to h2 database from java
- threadsafe singleton pattern in java
- java random between two strings
- spigot kill entity
- bukkit scheduled task