package com;
import java.io.FileReader;
import java.io.IOException;
import java.nio.charset.Charset;
public class demo {
public static void main(String[] args) throws IOException {
FileReader fr=new FileReader("C:\\Users\\彭新晨\\IdeaProjects\\untitled6\\1.txt", Charset.forName("GBK"));
int len;
while ((len=fr.read())!=-1){
System.out.println((char)len);
}
fr.close();
}
}
package com;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.Charset;
public class demo {
public static void main(String[] args) throws IOException {
FileWriter fw=new FileWriter("C:\\Users\\彭新晨\\IdeaProjects\\untitled6\\1.txt", Charset.forName("GBK"));
fw.write("你好你好");
fw.close();
}
}
package com;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.Charset;
public class demo {
public static void main(String[] args) throws IOException {
FileReader fr=new FileReader("C:\\Users\\彭新晨\\IdeaProjects\\untitled6\\1.txt", Charset.forName("GBK"));
FileWriter fw=new FileWriter("C:\\Users\\彭新晨\\IdeaProjects\\untitled6\\2.txt",Charset.forName("UTF-8"));
int len;
while ((len=fr.read())!=-1){
fw.write(len);
}
fw.close();
fr.close();
}
}
package com;
import java.io.*;
public class demo {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream("C:\\Users\\彭新晨\\IdeaProjects\\untitled6\\2.txt")));
String len;
while ((len=br.readLine())!=null){
System.out.println(len);
}
br.close();
}
}