- /**
- * 文件的顺序读写
- * 具体内容参阅本BLOG
- */
- import java.io.*;
- public class Test {
- public static void main(String[] args) throws Exception {
- // 字节输入流
- FileInputStream fis1 = new FileInputStream("C:/1.txt");
- File file1 = new File("C:/1.txt");
- FileInputStream fis2 = new FileInputStream(file1);
- // 字节输出流
- FileOutputStream fos1 = new FileOutputStream("C:/1.txt");
- FileOutputStream fos2 = new FileOutputStream("C:/1.txt", true);// 在有内容的文本中追加
- File file2 = new File("C:/1.txt");
- FileOutputStream fos3 = new FileOutputStream(file2);
- File file3 = new File("C:/1.txt");
- FileOutputStream fos4 = new FileOutputStream(file2, true);// 在有内容的文本中追加
- // 字符输入流
- BufferedReader in = new BufferedReader(new FileReader("C:/1.txt"));
- // 字符输出流
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
- "C:/1.txt")));
- /**
- * 文件的随机读写 具体内容参阅本BLOG
- */
- File file4 = new File("C:/1.txt");
- RandomAccessFile file = new RandomAccessFile(file4, "rw");
- }
- }
JDK6.0学习笔记(五)文件的顺序、随机读写
最新推荐文章于 2022-04-01 23:04:44 发布