java - How to append 4 digit number to the next string read from file -


i have 1 file read this

mytxt.txt

1234 http://www.abc.com  8754 http://www.xyz.com 

i tried this

try {           // make 'file' object            file file = new file("e:/mytxt.txt");           //  data file using file reader.            filereader fr = new filereader(file);           // store contents read via file reader           bufferedreader br = new bufferedreader(fr);                                                            // read br , store line in 'data', print data           string data;            while((data = br.readline()) != null)            {               //data = br.readline( );                                                    system.out.println(data);           }                                       } catch(ioexception e) {           system.out.println("bad !");    }   

i used actual question want read 1 2 charachter 1 one , appens digit link i'll read string. can tell me how suppose that..? appreciated.

parse line reading, search first white space (i'm assuming have 1 space separating digit , url) this:

try {       // make 'file' object        file file = new file("e:/mytxt.txt");       //  data file using file reader.        filereader fr = new filereader(file);       // store contents read via file reader       bufferedreader br = new bufferedreader(fr);     // read br , store line in 'data', print data       string data;        while((data = br.readline()) != null)        {           int poswhite = data.indexof(' ');         string digit = data.substring(0, poswhite);         string url = data.substring(poswhite + 1);         system.out.println(url + "/" + digit);       }                                   } catch(ioexception e) {       system.out.println("bad !");   }   

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -