import java.io.*;
class PrimitiveDemo
{
public static void main(String args[]) throws IOException
{
File primitive=new File("pri.txt");
FileOutputStream fos=new FileOutputStream(primitive);
DataOutputStream dos=new DataOutputStream(fos);
dos.writeInt(5);
dos.writeDouble(0.5);
dos.writeBoolean(false);
dos.writeChar('c');
dos.close();
fos.close();
// Read data from file
FileInputStream fis=new FileInputStream(primitive);
DataInputStream dis=new DataInputStream(fis);
System.out.println(dis.readInt());
System.out.println(dis.readDouble());
System.out.println(dis.readBoolean());
System.out.println(dis.readChar());
dos.close();
dos.close();
}
}
Deebugging help java exam's coming?
what's the problem?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment