Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- public class Main
- {
- public static void main(String[] args)
- {
- double[] liczby = { Math.PI, Math.PI/2, 7.5, 2, Math.E };
- try(FileOutputStream fos = new FileOutputStream("liczby.dat"))
- {
- DataOutputStream dos = new DataOutputStream(fos);
- for(int i = 0; i < liczby.length; i++)
- {
- dos.writeDouble(liczby[i]);
- }
- dos.flush();
- }
- catch(IOException e)
- {
- e.printStackTrace();
- }
- try(FileInputStream fis = new FileInputStream("liczby.dat"))
- {
- DataInputStream dis = new DataInputStream(fis);
- while(dis.available() != 0)
- {
- double current = dis.readDouble();
- System.out.println(current);
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement