I/O方式

缓冲输入文件

BufferdReader in = new BufferedReader(new FileReader(filename));

in.readLine();



从内存输入

StringReader in = new StringReader(BufferedInputFile.read(filename));

in.read();



格式化的内存输入

DataInputStream in = new DataInputStream(new ByteArrayInputStream(BufferedInputFile.read(filename).getBytes()));

in.readByte();



基本的文件输出

PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(filename)));

out.println();



文本文件输出的快捷方式

PrintWriter out = new PrintWriter(filename);

out.println();



存储和恢复数据

DataOutputStream out = new DataOutputStream(new BufferedOutputStream(filename));

out.writeXxx();

DateInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(filename)));

in.readXxx();



读写随机访问文件

RandomAccessFile rf = new RandomAccessFile(filename, "rw");

rf.readXxx();

rf.writeXxx();



*BufferedInputFile.read

BufferedReader in = new BufferedReader(new FileReader(filename));

in.readLine();

你可能感兴趣的:(I/O)