Guest User

Untitled

a guest
Jan 23rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3.  
  4. class Wykaz1{
  5. public static void main(String[] args) throws IOException{
  6.  
  7. DataOutputStream wyjsciowyBin = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("binarny")));
  8. Scanner wejsciowyTxt = new Scanner(new File("tekstowy"));
  9.  
  10. while(wejsciowyTxt.hasNext()){
  11. wyjsciowyBin.writeUTF(wejsciowyTxt.next());
  12. wyjsciowyBin.writeInt(Integer.parseInt(wejsciowyTxt.next()));
  13. }
  14. wejsciowyTxt.close();
  15. wyjsciowyBin.close();
  16.  
  17. ////
  18.  
  19.  
  20.  
  21.  
  22. //System.out.println(wejscieBin.readUTF());
  23. //System.out.println(wejscieBin.readInt());
  24.  
  25. try{
  26. DataInputStream wejscieBin = new DataInputStream(new BufferedInputStream(new FileInputStream("binarny")));
  27. while(true){
  28. System.out.println(wejscieBin.readUTF());
  29. System.out.println(wejscieBin.readInt());
  30. }
  31. } catch (EOFException e){} //wyjscie z petli czytajacej
  32.  
  33.  
  34. //wejscieBin.readUTF();
  35. //wejscieBin.readInt();
  36.  
  37.  
  38.  
  39.  
  40. }
  41. }
Add Comment
Please, Sign In to add comment