i trying parse html website specific data. following method reads source , outputs string processed other methods.
stringbuilder source = new stringbuilder(); url url = new url(urlin); urlconnection spoof; spoof = url.openconnection(); spoof.setrequestproperty( "user-agent", "mozilla/4.0 (compatible; msie 5.5; windows nt 5.0; h010818)" ); bufferedreader in = new bufferedreader(new inputstreamreader(spoof.getinputstream())); string strline = ""; while ((strline = in.readline()) != null){ source.append(strline); } return source.tostring(); the problem i'm having since call method multiple times different urlin argument each time, method gets stuck @ readline command. read because readline looks line break , if bufferedreader object not contain 1 whatever reason, stuck indefinitely.
is there way check whether bufferedreader object contains line break before run readline command. tried using if (in.tostring().contains("\n")) returns false. alternatively, add "\n" @ end of buffered reader "in" object every time while loop break , not hang indefinitely?
any appreciated.
okay, here should looking for.
fis = new fileinputstream("c:/sample.txt"); reader = new bufferedreader(new inputstreamreader(fis)); system.out.println("reading file line line using bufferedreader"); string line = reader.readline(); while(line != null){ system.out.println(line); line = reader.readline(); } edit, in case, since seems doing webapp testing, believe webdriverwait may work needs.
Comments
Post a Comment