java - reading parts of a txt file -


i have text file following urls:

http://www.google.com.uy http://www.google.com.es http://www.google.com.nz 

i need read second line of txt, second url showed there. i've been researching , didn't find need, because, although know have use bufferedreader class, don't know how specify "line" want read.

this wrote far:

string fileread = "chlist\\gather.txt"; try {                                              bufferedreader br = new bufferedreader(new filereader(fileread));     string gathertext = br.readline();     br.close(); } catch (ioexception ioe) {} 

each call br.readline(); return line text file , move next line, second call give line want. simplest way write:

string fileread = "chlist\\gather.txt";     try {                                                  bufferedreader br = new bufferedreader(new filereader(fileread));         br.readline();         string gathertext = br.readline();         br.close(); } catch (ioexception ioe) {} 

although should consider if file not contain 2 lines.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -