java中io之Reader的demo

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_20172379/article/details/87916413

import java.io.File;
import java.io.FileReader;
import java.io.Reader;

public class ReaderDemo {
public static void main(String[] args) throws Exception{
File file = new File(“c:”+File.separator+“study3”+File.separator+“kwg.txt”);
if(!file.getParentFile().exists()){
file.getParentFile().mkdirs();
}
Reader in = new FileReader(file);
char [] data =new char[1024];
int len = in.read(data);
in.close();
System.out.println(new String(data,0,len));

}

}

猜你喜欢

转载自blog.csdn.net/qq_20172379/article/details/87916413