안드로이드

int,byte,double,boolean, 문자열을 가지고 파일에 출력하는 예제 FileOutputStream DataOutputStream

raulyo 2012. 2. 22. 16:31
FileOutputStream fos = null;
        DataOutputStream dos = null;
        try{
        fos = new FileOutputStream("data.bin");
        dos = new DataOutputStream(fos);
        dos.writeBoolean(true);
        dos.writeByte((byte)5);
        dos.writeInt(100);
        dos.writeDouble(200.5);
        dos.writeUTF("hello world");
        }catch (Exception e) {
// TODO: handle exception
}finally{
try{
fos.close();
dos.close();
}catch (Exception e) {
// TODO: handle exception
}
}