티스토리 뷰
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 DataIOTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
// 텍스트파일에 데이터를 출력하고
// 다시 불러 들어와 콘솔화면에 출력해주는 프로그램
try {
DataOutputStream dataout = new DataOutputStream(
new FileOutputStream("D:\\test.txt"));
try {
dataout.writeInt(123);
dataout.writeChar('k');
dataout.writeDouble(123.4);
dataout.close();
DataInputStream datain = new DataInputStream(
new FileInputStream("D:\\test.txt"));
System.out.println(datain.readInt());
System.out.println(datain.readChar());
System.out.println(datain.readDouble());
datain.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
'java,web study > 4주차 (7월 22일~28일)' 카테고리의 다른 글
FileDelete (0) | 2013.07.22 |
---|---|
FileInfo (0) | 2013.07.22 |
RandomFileTest (0) | 2013.07.22 |
BufferReader (0) | 2013.07.22 |
InputStreamTest (0) | 2013.07.22 |