public final static void main(String[] args) throws Exception { |
new StringDeserialized().testDescirialized(); |
} |
public void testDescirialized() throws Exception { |
String testString = “http: //yuncode.net”; |
ObjectOutputStream dataOutStream = new ObjectOutputStream( new FileOutputStream(“. / stringdeserialized.data”)); |
for ( int i = 0 ; i < 1000 ; i++) |
dataOutStream.writeObject(testString); |
dataOutStream.close(); |
List<String> readAgainList = new ArrayList<String>( 100 ); |
for ( int i = 0 ; i < 100 ; i++) { |
ObjectInputStream dataInputStream = new ObjectInputStream( new FileInputStream(“. / stringdeserialized.data”)); |
readAgainList.add((String) dataInputStream.readObject()); |
dataInputStream.close(); |
} |
Thread.sleep(Integer.MAX_VALUE); |
} |