Java文件读写操作指定编码方式。。。。。
读:
File file=new File(this.filePath);
BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(file),"utf-8"));
String line=null;
while((line=br.readLine())!=null){
if(!line.trim().equals("")){
if(checkDuplicateRow(line.trim()))
tempList.add(line.trim());
}
}
写:
File filename = new File("xxx");
filename.createNewFile();
FileWriter fw = new FileWriter(filename);
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename),"GBk")));
out.write(hexToString(search_result));
out.flush();
out.close();
posted on 2014-03-07 11:42 lovebeauty 阅读(40114) 评论(1) 编辑 收藏 举报