package com.itheima.convertedio;
import java.io.*;
import java.nio.charset.Charset;
public class ConverteDemo1 {
public static void main(String[] args) throws IOException {
//method1();
//mthode2();
FileReader fr=new FileReader(".//a.txt", Charset.forName("UTF-8"));
int ch;
while ((ch=fr.read())!=-1){
System.out.println((char) ch);
}
fr.close();
}
private static void mthode2() throws IOException {
InputStreamReader isr=new InputStreamReader(new FileInputStream(".\\a.txt"),"UTf-8");
int ch;
while ((ch=isr.read())!=-1){
System.out.println((char) ch);
}
isr.close();
OutputStreamWriter osw=new OutputStreamWriter(new FileOutputStream(".\\a.txt"),"UTF-8");
osw.write("我爱学习,谁也别打扰我");
osw.close();
}
private static void method1() throws IOException {
FileReader fr=new FileReader(".\\a.txt");
int ch;
while ((ch=fr.read())!=-1){
System.out.println((char) ch);
}
}
}