Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- class Wykaz1{
- public static void main(String[] args) throws IOException{
- DataOutputStream wyjsciowyBin = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("binarny")));
- Scanner wejsciowyTxt = new Scanner(new File("tekstowy"));
- while(wejsciowyTxt.hasNext()){
- wyjsciowyBin.writeUTF(wejsciowyTxt.next());
- wyjsciowyBin.writeInt(Integer.parseInt(wejsciowyTxt.next()));
- }
- wejsciowyTxt.close();
- wyjsciowyBin.close();
- ////
- //System.out.println(wejscieBin.readUTF());
- //System.out.println(wejscieBin.readInt());
- try{
- DataInputStream wejscieBin = new DataInputStream(new BufferedInputStream(new FileInputStream("binarny")));
- while(true){
- System.out.println(wejscieBin.readUTF());
- System.out.println(wejscieBin.readInt());
- }
- } catch (EOFException e){} //wyjscie z petli czytajacej
- //wejscieBin.readUTF();
- //wejscieBin.readInt();
- }
- }
Add Comment
Please, Sign In to add comment