字符流-->字符流的底层其实就是字节流
public class Stream {
public static void main(String[] args) throws IOException {
//1.创建对象并关联本地文件
FileReader fr=new FileReader("abc\\a.txt");
//2.读取资源read()
int ch;
while((ch=fr.read())!=-1){
System.out.print(ch);
}
//3.释放资源
fr.close();
}
}
public class Stream {
public static void main(String[] args) throws IOException {
//1.创建对象
FileReader fr=new FileReader("abc\\a.txt");
//2.读取资源read()
char [] chars=new char[2];
int len;
while((ch=fr.read(chars))!=-1){
System.out.print(new String(chars,0,len));
}
//3.释放资源
fr.close();
}
}
FileWriter
public class Stream1 {
public static void main(String[] args) throws IOException {
FileWriter fw=new FileWriter("abc\\a.txt");
char[] chars={'a','b','c','你'};
fw.write(chars);
fw.close();
}
}