is there way access specific line in file (without looping) java - libgdx

ⅰ亾dé卋堺 提交于 2020-02-06 08:08:17

问题


Hi i am using LibGDX to program android.

Is there some way to sraightforward access specific line on the file without going through all the lines and reading them until i reach desired line? (Can I just say I want to read line number so-and-so?)

I know there are such methods:

FileHandle file = Gdx.files.internal("list.txt");
BufferedReader reader = new BufferedReader(file.reader());
reader.readLine();   <--- but it reads only first line !
//// or using scanner
scanner1 = new Scanner(new File("list.txt"));
scanner1.nextLine();   <--- also reads first line ..

Can I do it without looping through unnecessary lines? Any solutions, workarounds welcome. Thanx

来源:https://stackoverflow.com/questions/28940276/is-there-way-access-specific-line-in-file-without-looping-java-libgdx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!