package org.jimmy.autosearch2019.test;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Test20190412 {
public static void main(String[] args) {
}
public static ArrayList<String> readFile(int cacheLength, String filePath, String codedFormat) throws Exception {
FileInputStream fis = new FileInputStream(filePath);
BufferedReader br = new BufferedReader(new InputStreamReader(fis, codedFormat));
int fileLength = fis.available();
if(fileLength < cacheLength) {
cacheLength = fileLength;
}
int len = cacheLength;
char[] chars = new char[cacheLength];
while((len = br.read(chars, 0, len)) != -1) {
String text = new String(chars);
System.out.println(text);
}
br.close();
fis.close();
return null;
}
}
直接上代码.