Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. package com.javarush.task.task20.task2011;
  2.  
  3. import java.io.Externalizable;
  4. import java.io.IOException;
  5. import java.io.ObjectInput;
  6. import java.io.ObjectOutput;
  7.  
  8. /*
  9. Externalizable для апартаментов
  10. */
  11. public class Solution
  12. {
  13.  
  14. public static class Apartment implements Externalizable
  15. {
  16.  
  17. private String address;
  18. private int year;
  19.  
  20. /**
  21. * Mandatory public no-arg constructor.
  22. */
  23. public Apartment()
  24. {
  25. super ( );
  26. }
  27.  
  28. public Apartment(String adr, int y)
  29. {
  30. address = adr;
  31. year = y;
  32. }
  33.  
  34. /**
  35. * Prints out the fields. used for testing!
  36. */
  37. public String toString()
  38. {
  39. return ("Address: " + address + "\n" + "Year: " + year);
  40. }
  41.  
  42. @Override
  43. public void writeExternal(ObjectOutput out) throws IOException
  44. {
  45. out.writeObject (address);
  46. out.writeInt (year);
  47. }
  48.  
  49. @Override
  50. public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
  51. {
  52. address =(String)in.readObject ( );
  53. year = in.readInt ( );
  54. }
  55. }
  56.  
  57. public static void main(String[] args)
  58. {
  59.  
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement