文件逐行读取-转码
没啥技术含量,就是个容易忘记的代码
package cn.swsk.xbry.md1000.controller;
import org.apache.commons.io.FileUtils;
import java.io.*;
import java.util.Scanner;
/**
* @author css
* @date 2019/8/20 15:33
*/
public class Test {
public static void main(String[] args) throws IOException {
File file = new File("D:\\SWSK\\XBRY\\lightningPosition\\flash2019060523.txt");
// System.out.println(FileUtils.readFileToString(file));
// System.out.println(FileUtils.readFileToString(file,"UTF-8"));
// System.out.println(FileUtils.readFileToString(file,"GBK"));
InputStream is = FileUtils.openInputStream(file);
InputStreamReader isr = new InputStreamReader(is,"GBK");
BufferedReader reader = new BufferedReader(isr);
String s = reader.readLine();
System.out.println(s);
}
}
疯狂的妞妞 :每一天,做什么都好,不要什么都不做!