package com.buaa.comparable;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;

public class TestRead {

/*static void parse(char[] c,String str){
str = str.copyValueOf(c);
try {
str = new String(str.getBytes("gbk"),"utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}*/
public static void main(String[] args) {
testReader();

}
static void testReader(){
File f = new File("d:/a.txt");
FileInputStream fis = null;
try {
fis = new FileInputStream(f);
InputStreamReader isr = new InputStreamReader(fis,"utf-8");
int temp = 0;
while((temp=isr.read())!=-1){
char c = (char) temp;

System.out.print(c);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
if (fis!=null) {
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

相关文章:

  • 2022-12-23
  • 2021-09-24
  • 2022-01-16
  • 2021-09-08
  • 2021-08-12
  • 2021-05-14
  • 2022-12-23
  • 2021-11-07
猜你喜欢
  • 2022-12-23
  • 2021-10-01
  • 2022-12-23
  • 2021-06-01
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
相关资源
相似解决方案