范文健康探索娱乐情感热点
投稿投诉
热点动态
科技财经
情感日志
励志美文
娱乐时尚
游戏搞笑
探索旅游
历史星座
健康养生
美丽育儿
范文作文
教案论文
国学影视

JavaIO流

  IO流:随用随创建 不用要关闭
  IO流的作用
  IO流的分类
  IO流的体系
  FileOutputStream
  import java.io.FileOutputStream; import java.io.IOException;  public class FileOutputStreamDemo {     public static void main(String[] args) throws IOException {          /*             void write(byte[] b, int off, int len)              参数一:数组             参数二:起始索引             参数三:个数          */          // 创建字节输出流对象         FileOutputStream fos = new FileOutputStream("a.txt");          // 写出数据         byte[] bytes = {97,98,99,100,101};          /*             bytes: 数组             off: 起始索引             len: 个数          */         fos.write(bytes, 1, 2);          // 释放资源         fos.close();     } } FileInputStream
  read:表示读取数据,而且读取一个数据就移动一次指针
  一次读写一个字节import java.io.FileInputStream; import java.io.IOException;  public class FileInputStreamDemo {     public static void main(String[] args) throws IOException {          // 创建流对象         FileInputStream fis = new FileInputStream("a.txt");          // 循环读取         // read: 表示读取数据,而且是读取一个数据就移动一次指针         int b;         while (( b = fis.read()) != -1 ) {             // 在循环判断中读过了,所以在循环体中就不需要再读了             System.out.println((char)b);         }          // 释放资源         fis.close();     } }
  一次读写多个字节
  》》》如果每次读取的字节数组不指定个数(len),导致最后读取的结果会有问题
  问题:每次读取的字节都会覆盖前一次的结果,可能导致最后读取的结果有问题
  》》》解决方案:每次读取数组指定个数(len)
  import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException;  public class FileInOutputStreamDemo {     public static void main(String[] args) throws IOException {          // 创建流对象         FileInputStream fis = new FileInputStream("a.txt");         FileOutputStream fos = new FileOutputStream("b.txt");          // 拷贝         int len; // 个数         // 一次读取多个字节数         byte[] bytes = new byte[1024 * 1024 * 5];          while (( len = fis.read()) != -1 ) {             // 每次读取字节,需加上个数(len),避免最后读取结果出现问题             fos.write(bytes, 0, len);         }          // 释放资源(先开先关闭)         fos.close();         fis.close();     } } 异常处理
  import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException;  public class FileInOutputStreamDemo {     public static void main(String[] args) throws FileNotFoundException {          // 创建流对象         FileInputStream fis = new FileInputStream("a.txt");         FileOutputStream fos = new FileOutputStream("b.txt");          try (fis; fos) {             // 拷贝             int len; // 个数             // 一次读取多个字节数             byte[] bytes = new byte[1024 * 1024 * 5];              while (( len = fis.read()) != -1 ) {                 // 每次读取字节,需加上个数(len),避免最后读取结果出现问题                 fos.write(bytes, 0, len);             }         } catch (IOException e) {             e.printStackTrace();         }     } } 字符集
  ASCII
  GBK:两个字节
  Unicode
  UTF-8:三个字节
  乱码原因
  避免产生乱码
  import java.io.UnsupportedEncodingException; import java.util.Arrays;  public class EncodeDecode {     public static void main(String[] args) throws UnsupportedEncodingException {         /*             编码方式:                 public byte[] getBytes()                       默认方式                 public byte[] getBytes(String charsetName)     指定方式进行编码              解码方式:                 String(byte[] bytes)                           默认方式                 String(byte[] bytes, String charsetName)       指定方式解码          */          // 编码         String str = "你好啊";         byte[] bytes01 = str.getBytes();         System.out.println(Arrays.toString(bytes01));          byte[] bytes02 = str.getBytes("GBK");         System.out.println(Arrays.toString(bytes02));          System.out.println("================================================");          // 解码         String str2 = new String(bytes01);         System.out.println("bytes01 str2: " + str2);          String str3 = new String(bytes01, "GBK");         // 编码和解码不一致,导致乱码         System.out.println("bytes01 str3: " + str3);          System.out.println("================================================");           String str4 = new String(bytes02, "GBK");         System.out.println("bytes02 str4: " + str4);     } }
  字符流
  FileReader
  import java.io.FileReader; import java.io.IOException;  public class FileReaderDemo {     public static void main(String[] args) throws IOException {          // 创建对象并关联本地文件         FileReader fr = new FileReader("a.txt");          // 无参读取数据         // 字符流的底层也是字节流,默认也是一个字节一个字节的读取         // 遇到中文就会一次读取多个,GBK一次读两个字节,UTF-8一次读三个字节         // 读取之后,方法的底层还会进行解码并转成十进制,最后将十进制作为返回值         // 英文和中文: 文件里面的二进制数据,通过read方法进行读取,解码并转成十进制 //        int ch; //        while ((ch = fr.read()) != -1) { //            // 将十进制数据,强转成中文 //            System.out.println((char) ch); //        }                  // 有参读取数据         char[] chs = new char[2];         int len;         // read(chs): 读取数据、解码、强转三步合并了,把强转之后的字符放到数组当中         while ((len = fr.read(chs)) != -1) {             // 把数组中的数据变成字符串再进行打印             System.out.println(new String(chs, 0, len));         }                  // 释放资源         fr.close();     } }FileWriter
  根据字符集的编码方式进行编码,把编码之后的数据写到文件中去
  import java.io.FileWriter; import java.io.IOException;  public class FileWriterDemo {     public static void main(String[] args) throws IOException {          // 创建对象         FileWriter fw = new FileWriter("b.txt", true);                  // 写数据         char[] chars = {"a", "b", "c", "d", "e", "f","我"};         fw.write(chars);                  // 释放资源         fw.close();     } }字符输入流原理
  import java.io.FileReader; import java.io.FileWriter; import java.io.IOException;  public class FileReaderWriterDemo {     public static void main(String[] args) throws IOException {          // 创建对象         FileReader fr = new FileReader("b.txt");         fr.read(); // 会把文件中的数据放到缓冲区当中          // 清空文件,不会清空缓冲区的数据(**特别注意**)         FileWriter fw = new FileWriter("b.txt");          int ch;         while ((ch = fr.read()) != -1) {             System.out.println((char)ch); // 读的是缓冲区的数据         }          // 释放资源         fw.close();         fr.close();     } }字符输出流原理
  装满了、flush、close都会把数据放到目的地
  文件拷贝import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException;  public class CopyFile {      public static void main(String[] args) throws IOException {          // 1. 创建源对象         File src = new File("D:aaasrc");          // 2. 创建对象表示目的地         File dest = new File("D:aaadest");          // 3. 调用方法开始拷贝         copydir(src, dest);     }      private static void copydir(File src, File dest) throws IOException {         dest.mkdirs(); // 如果文件夹不存在,就创建,文件存在,也不会报错。          // 递归         // 进入数据源         File[] files = src.listFiles();          // 遍历数组         for (File file : files) {             if (file.isFile()) {                 // 判断是文件,拷贝                 FileInputStream fis = new FileInputStream(file);                 // 文件拷贝到目的地                 FileOutputStream fos = new FileOutputStream(new File(dest, file.getName()));                  byte[] bytes = new byte[1024];                 int len;                 while ((len = fis.read(bytes)) != -1) {                     fos.write(bytes, 0, len);                 }                  fos.close();                 fis.close();             } else {                 // 判断文件夹,递归                 // dest文件夹没有需提前创建                 copydir(file, new File(dest, file.getName()));             }         }     } }修改文件中数据方式一import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.stream.Collectors;  public class OrderContextFile {     public static void main(String[] args) throws IOException {         // 2-1-9-4-7-8         // 读取数据         FileReader fr = new FileReader("a.txt");         StringBuilder sb = new StringBuilder();          int ch;         while ((ch = fr.read()) != -1) {             sb.append((char)ch);         }          // 释放资源         fr.close();          String str = sb.toString();         String[] arrStr = str.split("-");          ArrayList list = new ArrayList();         for (String s : arrStr) {             int i = Integer.parseInt(s);             list.add(i);         }          // 排序         Collectors.sort(list);          // 写出数据         FileWriter fw = new FileWriter("b.txt");         for (int i = 0; i < list.size(); i++) {             if (i == list.size() - 1) {                 fw.write(list.get(i) + ""); // "" 数字转成字符串,能保证原样输出             } else {                 fw.write(list.get(i) + "-");             }         }          // 释放资源         fw.close();     } }方式二import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.Arrays;  /*     ①文件中的数据不要换行,②开头不要有bom头,否则会影响数据的结果。  */ public class OrderContextFile {     public static void main(String[] args) throws IOException {         // 2-1-9-4-7-8         // 读取数据         FileReader fr = new FileReader("a.txt");         StringBuilder sb = new StringBuilder();          int ch;         while ((ch = fr.read()) != -1) {             sb.append((char)ch);         }          // 释放资源         fr.close();          // 使用流         Integer[] arr = Arrays.stream(sb.toString().split("-")/*切割之后为字符串数组*/)                 .map(Integer::parseInt)                 .sorted()                 .toArray(Integer[]::new);         // 写出         FileWriter fw = new FileWriter("a.txt");          String s = Arrays.toString(arr).replace(",", "-"); // 数组         // 字符串截取前后的[]         String result = s.substring(1, s.length() - 1);          fw.write(result);          // 释放资源         fw.close();     } }缓冲流
  字节缓冲流
  import java.io.*;  public class BufferedStreamDemo {     public static void main(String[] args) throws IOException {          // 创建缓冲流对象         BufferedInputStream bis = new BufferedInputStream(new FileInputStream("a.txt"));         BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("b.txt"));          // 循环读取并写到目的地         // 拷贝(一次读写多个字节)         byte[] bytes = new byte[1024];         int len;         while ((len = bis.read()) != -1) {             bos.write(bytes, 0, len);         }          // 释放资源         bos.close();         bis.close();     } }字符缓冲流原理
  字符缓冲流
  import java.io.*; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator;  /* 		第一种方法:     给a.txt的内容排序,然后输出     a.txt :         4. hello         3. Hi         1. world         2. java  */ public class BufferedStreamDemo {     public static void main(String[] args) throws IOException {          // 读取数据         BufferedReader br = new BufferedReader(new FileReader("a.txt"));          ArrayList list = new ArrayList<>();          String line;         while ((line = br.readLine()) != null) {             list.add(line);         }          br.close();          // 排序:按照每一行前面的序号进行排列         Collections.sort(list, new Comparator() {              @Override             public int compare(String o1, String o2) {                  // 获取o1和o2的序号                 int i1 = Integer.parseInt(o1.split(".")[0]);                 int i2 = Integer.parseInt(o2.split(".")[0]);                 return i1 - i2;             }         });          //写出         BufferedWriter bw = new BufferedWriter(new FileWriter("b.txt"));         for (String str : list) {             bw.write(str);             bw.newLine(); // 换行         }          // 释放资源         bw.close();     } }import java.io.*; import java.util.Map; import java.util.Set; import java.util.TreeMap;  /*     第二种方法:     给a.txt的内容排序,然后输出     a.txt :         4. hello         3. Hi         1. world         2. java  */ public class BufferedStreamDemo {     public static void main(String[] args) throws IOException {          // 读取数据         BufferedReader br = new BufferedReader(new FileReader("a.txt"));          // TreeMap可以自动排序         TreeMap treeMap = new TreeMap<>();          String line;         while ((line = br.readLine()) != null) {             String[] arr = line.split(".");              treeMap.put(Integer.parseInt(arr[0]), line);         }          br.close();          //写出         BufferedWriter bw = new BufferedWriter(new FileWriter("b.txt"));          Set> entries = treeMap.entrySet();          for (Map.Entry entry : entries) {             bw.write(entry.getValue());             bw.newLine();         }          // 释放资源         bw.close();     } }import java.io.*;   /*     实现一个验证运行次数的小程序         不能定义count变量,因为变量在内存运行之后会消失的,所以计数器的变量保存在文件中永久性存储  */ public class BufferedStreamDemo {     public static void main(String[] args) throws IOException {          // 把文件中的数字读取到内存中         BufferedReader br = new BufferedReader(new FileReader("count.txt"));         String line = br.readLine();         int count = Integer.parseInt(line);         count++;          // 判断         if (count <=3) {             System.out.println("第"+ count +"次免费使用");         } else {             System.out.println("软件超过3次免费使用,请注册!!!");         }          // 自增count值要写入文件中         BufferedWriter bw = new BufferedWriter(new FileWriter("count.txt"));         bw.write(count + ""); // 加上""后,count的值是以字符串写入文件,避免数字发生转换          bw.close();         br.close();     } }转换流
  import java.io.*; import java.nio.charset.Charset;  public class ConvertStreamDemo {     public static void main(String[] args) throws IOException {         // 利用转换流按照指定字符编码读取          // 创建对象并指定字符编码 //        InputStreamReader isr = new InputStreamReader(new FileInputStream("a.txt"), "GBK"); // //        // 读取数据 //        int ch; // //        while ((ch = isr.read()) != -1) { //            System.out.println((char)ch); //        } // //        // 释放资源 //        isr.close();          // JDK11 替代方案         FileReader fr = new FileReader("a.txt", Charset.forName("GBK"));          // 读取数据         int ch;          while ((ch = fr.read()) != -1) {             System.out.println((char)ch);         }          // 释放资源         fr.close();     } }import java.io.*; import java.nio.charset.Charset;  public class ConvertStreamDemo {     public static void main(String[] args) throws IOException {         // 利用转换流按照指定字符编码写出          // 创建转换流的对象 //        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("b.txt"), "GBK"); // //        // 写出数据 //        osw.write("你好你好"); // //        // 释放资源 //        osw.close();          // JDK11 替代方案         FileWriter fw = new FileWriter("b.txt", Charset.forName("GBK"));         fw.write("你好你好");         fw.close();     } }import java.io.*; import java.nio.charset.Charset;  public class ConvertStreamDemo {     public static void main(String[] args) throws IOException {         // 将本地文件的GBK文件,转成UTF-8          // JDK11以前的方案 //        InputStreamReader isr = new InputStreamReader(new FileInputStream("a.txt"), "GBK"); //        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("b.txt"), "UTF-8"); // //        int b; //        while ((b = isr.read()) != -1) { //            osw.write(b); //        } // //        osw.close(); //        isr.close();          // JDK11替代方案         FileReader fr = new FileReader("a.txt", Charset.forName("GBK"));         FileWriter fw = new FileWriter("b.txt", Charset.forName("UTF-8"));          int b;         while ((b = fr.read()) != -1) {             fw.write(b);         }          fr.close();         fw.close();     } }import java.io.*;  public class ConvertStreamDemo {     public static void main(String[] args) throws IOException {         // 利用字节流读取文件中的数据,每次读一整行,而且不能出现乱码          // 字节流在读取中文的时候,会出现乱码的,但是字符流可以搞定         // 字节流里卖弄是没有读一整行的方法,只有字符流缓冲流才能搞定         FileInputStream fis = new FileInputStream("a.txt");         InputStreamReader isr = new InputStreamReader(fis);         // 读取一整行         BufferedReader br = new BufferedReader(isr);          String line;         while ((line = br.readLine()) != null) {             System.out.println(line);         }          br.close();     } }对象操作流
  序列化/反序列化:数据读到最后会报EOFException。
  注意:序列化/反序列化一定是先写后读。序列化流
  import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream;  public class ObjectStreamDemo {     public static void main(String[] args) throws IOException {          // 创建对象         Student student = new Student("zhangsan", 23);          // 创建序列化流的对象/对象操作输出流         ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("a.txt"));          // 写出数据         oos.writeObject(student);          // 释放资源         oos.close();     } }反序列化流
  import java.io.*;  public class ObjectStreamDemo {     public static void main(String[] args) throws IOException, ClassNotFoundException {          // 创建反序列化流的对象         ObjectInputStream ois = new ObjectInputStream(new FileInputStream("a.txt"));                  // 读取数据         Student student = (Student) ois.readObject();          // 打印对象         System.out.println("student = " + student);                  // 释放资源         ois.close();     } }
  import java.io.*; import java.util.ArrayList;  public class ObjectStreamDemo {     public static void main(String[] args) throws IOException, ClassNotFoundException {          // 序列化多个对象         Student s1 = new Student("zhangsan", 23, "南京");         Student s2 = new Student("lisi", 24, "重庆");         Student s3 = new Student("wangwu", 26, "四川");          // 优化         ArrayList list = new ArrayList<>();         list.add(s1);         list.add(s2);         list.add(s3);          // 创建序列化流对象         ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("a.txt"));          // 缺点:如果序列化对象多少次未知,会导致反序列化报异常 //        oos.writeObject(s1); //        oos.writeObject(s2); //        oos.writeObject(s3);          oos.writeObject(list);          // 创建反序列化流对象         ObjectInputStream ois = new ObjectInputStream(new FileInputStream("a.txt")); //        Student stu1 = (Student) ois.readObject(); //        Student stu2 = (Student) ois.readObject(); //        Student stu3 = (Student) ois.readObject();  //        System.out.println("stu1 = " + stu1); //        System.out.println("stu2 = " + stu2); //        System.out.println("stu3 = " + stu3);          // 优化         ArrayList students = (ArrayList) ois.readObject();          for (Student student : students) {             System.out.println("student = " + student);         }          // 释放资源         ois.close();         oos.close();     } }打印流:只能打印
  字节打印流
  import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; import java.nio.charset.Charset;  public class PrintStreamDemo {     public static void main(String[] args) throws FileNotFoundException {          // 创建打印流对象         PrintStream ps = new PrintStream(new FileOutputStream("a.txt"), true, Charset.forName("UTF-8"));          // 写出数据 自动刷新 自动换行         ps.println(97); // 数据原样写出         ps.print("hello world!");         ps.printf("%s java", "hello");          // 释放资源         ps.close();     } }字符打印流
  import java.io.FileWriter; import java.io.IOException; import java.io.PrintStream; import java.io.PrintWriter;  public class PrintWriterDemo {     public static void main(String[] args) throws IOException {          // 创建字符打印流对象         PrintWriter pw = new PrintWriter(new FileWriter("a.txt"), true);          // 写出数据         pw.println("hello world");          // 特殊的打印流,系统中的标准输出流,是系统唯一的         PrintStream ps = System.out;         ps.println("123");          // 释放资源         ps.close();         pw.close();     } }
  解/压缩流
  解压缩流
  import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream;  public class ZipStreamDemo {     public static void main(String[] args) throws IOException {          // 创建一个File的压缩包         File src = new File("aaa.zip");         // 创建一个File解压的目的地         File dest = new File("D:");          unzip(src, dest);     }      // 定义解压的方法     public static void unzip(File src, File dest) throws IOException {         // 解压的本质:把压缩包里面的每一个文件或者文件夹读取出来,按照层级拷贝到目的地中         // 创建一个解压缩流用来读取压缩包中的数据         ZipInputStream zip = new ZipInputStream(new FileInputStream(src));          // 先获取到压缩包中的每一个zipentry对象 //        ZipEntry entry1 = zip.getNextEntry();          // 获取文件和文件夹         ZipEntry entry;         while ((entry = zip.getNextEntry()) != null) {              if (entry.isDirectory()) {                 // 文件夹:在dest就要创建文件夹                 File file = new File(dest, entry.toString());                  // 在dest下创建文件夹                 file.mkdirs();             } else {                 FileOutputStream fos = new FileOutputStream(new File(dest, entry.toString()));                 // 文件:需读取文件中的内容,而且需放到对应的dest文件夹中(按层级目录存放)                 int b;                 while ((b = zip.read()) != -1) {                     // 写到目的地                     fos.write(b);                 }                  fos.close();                 // 压缩包中一个文件处理完毕了                 zip.closeEntry();             }         }          // 释放资源         zip.close();     } }压缩流
  压缩单个文件import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream;  public class ZipStreamDemo {     public static void main(String[] args) throws IOException {         // 创建File对象表示要压缩的文件         File src = new File("D:a.txt");         // 创建File对象表示压缩包的位置         File dest = new File("D:");          // 调用方法用来压缩 				toZip(src, dest);     }      /**      * 作用:压缩      * @param src 压缩的文件      * @param dest 压缩包的位置      */     public static void toZip(File src, File dest) throws IOException {         // 创建压缩流关联压缩包         ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(new File(dest, "a.zip")));          // 创建ZipEntry对象,压缩包里面的每一个文件和文件夹         ZipEntry entry = new ZipEntry("a.txt");          // 把ZipEntry队形放到压缩包中         zos.putNextEntry(entry);          // 把src文件中的数据写到压缩包中         FileInputStream fis = new FileInputStream(src);          int b;         while ((b = fis.read()) != -1) {             zos.write(b);         }          // 释放资源         zos.closeEntry();         zos.close();     } }压缩文件夹import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream;  public class ZipStreamDemo {     public static void main(String[] args) throws IOException {         // 创建File对象表示要压缩的文件         File src = new File("D:aaa");         // 创建File对象表示压缩包的位置         File destParent = src.getParentFile();          // 创建File对象表示压缩包的路径         File dest = new File(destParent, src.getName() + ".zip");         // 创建关联压缩包         ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(dest));          // 获取src里面的每一个文件,变成ZipEntry对象,放入到压缩包当中         toZip(src, zos, src.getName());          // 释放资源         zos.close();     }      /**      * 获取src里卖弄的每一个文件,变成ZipEntry对象,放入压缩包中      * @param src 数据源      * @param zos 压缩流      * @param name 压缩包内部的路径      * @throws IOException      */     public static void toZip(File src, ZipOutputStream zos, String name) throws IOException {         // 进入src文件夹         File[] files = src.listFiles();          // 遍历数组         for (File file : files) {             // 文件,变成ZipEntry对象,放入到压缩包中             if (file.isFile()) {                 ZipEntry entry = new ZipEntry(name + "" + file.getName());                 zos.putNextEntry(entry);                  // 读取文件中的数据,写到压缩包                 FileInputStream fis = new FileInputStream(file);                  int b;                 while ((b = fis.read()) != -1) {                     zos.write(b);                 }                  fis.close();                 zos.closeEntry();             } else {                 // 文件夹                 toZip(file, zos, name + "" + file.getName());             }         }     } }Commons-io
  import org.apache.commons.io.FileUtils;  import java.io.File; import java.io.IOException;  public class CommonsIODemo {     public static void main(String[] args) throws IOException {          File src1 = new File("a.txt");         File dest1 = new File("copy.txt");          FileUtils.copyFile(src1, dest1); // copy文件          File src2 = new File("D:aaa");         File dest2 = new File("D:eee");          FileUtils.copyDirectory(src2, dest2); // copy文件夹          File dest3 = new File("D:eee");          FileUtils.cleanDirectory(dest3); // 删除文件夹里面的文件     } } Hutoll工具包     cn.hutool     hutool-all     5.8.16 
  import cn.hutool.core.io.FileUtil;  import java.io.File; import java.util.ArrayList; import java.util.List;  public class HuToolDemo {     public static void main(String[] args) {         File file = FileUtil.file("D:","aaa","bbb","a.txt");         System.out.println(file); // D:aaabbba.txt          File touch = FileUtil.touch(file); // 如果父级目录不存在,一并创建          ArrayList list = new ArrayList<>();         list.add("aaa");         list.add("bbb");         list.add("ccc");         list.add("ddd");          FileUtil.writeLines(list, "D:a.txt", "UTF-8", true); // 追加写入         FileUtil.appendLines(list, "D:a.txt", "UTF-8"); // 追加写入          List linesList = FileUtil.readLines("D:a.txt", "UTF-8"); //一行的数据是集合的一个元素     } }

别再说自己是三国迷了,根据线索猜人物,共十道题你能答对几个?第一题线索黄巾之乱入伍,效力韩馥袁绍线索官渡之战反水,曹操视若韩信线索宕渠之战败于翼德,街亭之战大胜幼常。请问这个人是谁?第二题线索十七岁追杀海盗,佐三县百姓爱戴线索逼死王叡杀张咨10张真实老照片1930年代大萧条席卷美国时,无家可归者的聚集地1930年代,当大萧条席卷美国的时候,胡佛村也如雨后春笋般在美国各地冒了出来。它是当时贫困人民所兴建的简易棚户区的流行名称。胡佛村这一名字,来自于时任美国第31任总统赫伯特胡佛,当长津湖一段英雄的回忆这就是一部爱国电影,他让我们对英雄满怀崇敬,让我们心怀感动与力量,让我们铭记历史!让我们了解下英雄的回忆!蓦然回望历史,我们发现,参与那场战争的志愿军战士们很多人已经九十岁左右了。楚汉战争中项羽失败的根本原因提到项羽这个名字,大家应该是很熟悉的,哪怕是不太关注历史的朋友们,也都知道一些有关项羽的事迹吧。迄今为止,许许多多有关于这位西楚霸王项羽的故事文学作品艺术作品流传于世,无论是易安居1956年女科学家历尽艰辛回国,为何隐姓埋名三十年?她都做了什么1964年,新中国第一颗原子弹,在新疆荒漠上成功爆炸,举国欢庆,全世界也为之轰动,作为领头人的邓稼先更是被誉为中国原子弹之父。人群中有一位头发花白的女科学家,在看到原子弹顺利爆炸之诺贝尔经济学奖今日将揭晓!今年有哪些大热门?北京时间10月11日1745,2021年诺贝尔经济学奖将揭晓。在颁奖规则回归常态后,宏观经济卫生和劳动力市场成为获奖关注的热门领域。据第一财经记者梳理,在过去10年中,获得诺贝尔经东德要独立,西德要挽留,德国统一却突如其来本来是同一国家,但分裂成两个政权的两部分,都要面对这两个问题一对方是什么?二其他国家把我们当成什么?二战后分裂为东西两部分的德国,自然也不例外。直到1990年统一,整部德国的分裂史黄晓明杨颖现身环球影视城,力破离婚传闻,baby生图太能打了吧最近,北京环球影视城盛大开业,这一个主题乐园也成为了全球第五大环球影视城,而在北京的这一个环球影视城的规模,也可以说是非常的大了,其中独特的功夫熊猫园区以及非常大的harrypot39岁的冻龄童颜张韶涵,曾分享维持身材秘诀,主要方法有三点导语一切所谓的负面情绪,经过跑步碾压都将变得微不足道世界以痛吻我,我要报之以歌。没有谁的人生是一番坦途,更多的是荆棘遍地。我们只有默默前行,才可能找寻到生命的光亮。一千种人有一千种吉克隽逸王子文同提1万3千包包,一个时髦到飞起一个像购物大妈吉克隽逸王子文同提1万3包包,一个时兴到飞起一个像购物大妈撞衫在文娱圈中真的不是件奇怪事,但是撞衫多见,撞包包的还真未几见。本以为同一件衣服穿在差别人身上会是不同样的感受,但同一款爸爸去哪儿8年了,10位女娃变化大,有人进入变美尴尬期2013年10月,迎着明星真人秀的热潮,芒果台播出了一档节目爸爸去哪儿。这档亲子类的真人秀播出之后,收视空前火爆,观众席卷老中青。一来,这是明星首次把个人生活放在台前播出,满足了观
苏炳添真自律,3大奥运冠军举起酒杯,他把茶杯举起,马龙笑了北京时间12月22日消息,在澳门进行访问交流的内地奥运健儿代表团迎来了聚餐,苏炳添马龙孙一文与吕小军同桌合影。有趣的是,当马龙孙一文与吕小军3位奥运冠军举起酒杯的时候,苏炳添只是把小米12系列手机官宣12月28日发布,首发三款机型今天上午,小米官方正式宣布,旗下小米12系列手机将于12月28日晚间正式发布。而从小米官方首张宣发海报来看,亚洲记录保持者,百米飞人苏炳添将成为小米12系列的手机代言人。结合小米创Log4j2再爆雷,Log4jv2。17。0横空出世Log4j2再爆雷Log4j2这是没完没了了,栈长以为Log4j2。16。0是最终终结版本了,没想到才过多久又爆雷了前两天栈长还说Log4j2。16。0是最安全的版本,没想到这么快漏洞利用接踵而至Apache为Log4j发布2。17。0新版补丁修复在Log4j漏洞曝光之后,Apache软件基金会于上周二发布了修补后的2。17。0新版本,并于周五晚些发布了一个新补丁。官方承认2。16版本无法在查找评估中妥善防止无限递归,因而易从WPS的发展史回看,倪光南口中的技工贸真的走不通吗?有关联想的话题这两天一直刷屏,从国有资产流失到倪柳之争人们假设如果联想当时走技工贸路线而不是贸工技,会不会到20年后的今天,我们在芯片领域就有了话语权。当然这都是假设,相比于倪柳之A股重现阳包阴强势反弹还是直接反转?大家好,我是小牛。今天是2021年12月21日,周二,下午1415,我们来做下今天的上证指数收评。先说一下昨天没有更新的原因很简单,被市场无情的打脸了,而且感觉受到了暴击的感觉。昨造车新势力再添新军轻橙时代首款量产车将亮相广州车展距离轻橙时代在2021年广州车展上亮相首款车型仅10天时间,这家此前在业界默默无闻的造车新势力高管们突然出现在公众面前,向大家介绍轻橙时代是一家融合智能科技与商业智慧,致力于为每个王力宏事件,田朴珺发言三观碎一地?网友群起围攻田朴珺理论一,艺术家都花心,不然没灵感二,男人不是圣人三,女人锤渣男前任或是现任,没人敢做朋友四,高学历不能做全职太太一,艺术家都花心?真敢说,按田朴珺说法,国家严查禁用娱乐圈出轨经典iPhone跌至新低,128GBIP68,二手机跌至2899元苹果多跟手机打交道,前段时间就有朋友问我,公司想给员工买一些二手iPhone当作工作机型,有没有便宜的渠道。我的意思是,想要价格便宜可以选择二手安卓旗舰,降价非常猛。但是这位朋友表外孙好动坐不住,姥姥用3个月陪娃玩出超强专注力,老师佩服朋友家孩子7月份时3岁,朋友把她送到离家很近的一个公立幼儿园,可是上幼儿园没多久,朋友就接二连三接到老师投诉,说孩子专注力一点也不好,规则感不强,上课不光自己不听老师的话,还带动着被米卢弃用无缘世界杯,多方博弈的牺牲品,中国最强右前卫李明中国的足球城大连曾孕育了一代代的出色足球运动员,前国脚李明无疑是其中的佼佼者之一,相貌英俊,温文尔雅的他见证了大连足球的辉煌,先后代表大连万达和大连实德获得8次中国顶级联赛冠军,为