Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. package com.alexey.task6;
  2.  
  3. import java.io.*;
  4.  
  5. public class StorageService<T extends Serializable> {
  6.  
  7. public T Load() throws IOException, ClassNotFoundException {
  8. FileInputStream fis = new FileInputStream("data.bindb");
  9. ObjectInputStream oin = new ObjectInputStream(fis);
  10. return (T) oin.readObject();
  11. }
  12.  
  13. public void Save(T data) throws IOException {
  14. FileOutputStream fos = new FileOutputStream("data.bindb");
  15. ObjectOutputStream oos = new ObjectOutputStream(fos);
  16. oos.writeObject(data);
  17. oos.flush();
  18. oos.close();
  19. }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement