본문 바로가기

안드로이드

int,byte,boolean,double,문자열을 파일에서 읽어들이는 예제 FileInputStream DataInputStream

 FileInputStream fis = null;
        DataInputStream dis = null;
        try{
        fis = new FileInputStream("data.bin");
        dis = new DataInputStream(fis);
        boolean b = dis.readBoolean();
        byte b2 = dis.readByte();
        int i = dis.readInt();
        double d = dis.readDouble();
        String s = dis.readUTF();
        }catch (Exception e) {
// TODO: handle exception
}finally{
try{
fis.close();
dis.close();
}catch (Exception e) {
// TODO: handle exception
}
}