I/O流
Posted 0426abc
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了I/O流相关的知识,希望对你有一定的参考价值。
import java.io.*;
public class FileTest
public static void main(String[] args)
// TODO 自动生成的方法存根
File file = new File("data.txt");
String s = "[email protected]#%&*软件工程";
try
FileWriter te = new FileWriter (file);
BufferedWriter out = new BufferedWriter (te);
out.write(s);
out.close();
te.close();
catch (Exception e)
e.printStackTrace();
try
FileReader fr = new FileReader(file);
BufferedReader in = new BufferedReader(fr);
String len = in.readLine();
System.out.println("文件中的信息是:"+ len);
in.close();
fr.close();
catch (Exception e)
e.printStackTrace();
public class FileTest
public static void main(String[] args)
// TODO 自动生成的方法存根
File file = new File("data.txt");
String s = "[email protected]#%&*软件工程";
try
FileWriter te = new FileWriter (file);
BufferedWriter out = new BufferedWriter (te);
out.write(s);
out.close();
te.close();
catch (Exception e)
e.printStackTrace();
try
FileReader fr = new FileReader(file);
BufferedReader in = new BufferedReader(fr);
String len = in.readLine();
System.out.println("文件中的信息是:"+ len);
in.close();
fr.close();
catch (Exception e)
e.printStackTrace();
以上是关于I/O流的主要内容,如果未能解决你的问题,请参考以下文章