1
안드로이드에서 텍스트 파일을 읽습니다. 나는 33 줄 이하의 더 작거나 더 작은 텍스트 파일을 가지고 있습니다. 큰 경우 33 행은 마지막 33 행을 읽습니다. 33 줄보다 작거나 같으면 모든 줄을 읽습니다. 가장 빠른 방법 것은 내가안드로이드에서 안드로이드는
MAXLINECOUNT=33;
File f = new File("file.......");
if (f.exists())
{
String readString = new String();
int i,l;
i=0;
l=0;
LineNumberReader reader = new LineNumberReader(new FileReader(new File("/mnt/sdcard/data.txt")));
while ((readString = reader.readLine()) != null) {}
l= reader.getLineNumber();
if (l>=MAXLINECOUNT) l=l-(MAXLINECOUNT-3);// i realy need only 30
FileInputStream fileIS = new FileInputStream(f);
BufferedReader buf = new BufferedReader(new InputStreamReader(fileIS));
while((readString = buf.readLine())!= null){
if (i>l)
{
process hear ...............
}
i++;
희망 http://stackoverflow.com/questions/2312756/in-java-how-to-read-from-a-file-a-specific-line-given-the-line- number – vnshetty
Android에 FileUtils이 없습니다. 찾을 수 없습니다. 텍스트 파일을 문자열로 전송하고 분석 할 수 있습니까? –
아무 것도 안드로이드 프로젝트에서 commons-fileutils를 사용할 수 없습니다 (크기는 예외) –