I am trying to read from 45 pages that are all the same (except for the part im reading of course) and write them in a list of line lists.
I wrote this code so far:
public static ArrayList<ArrayList<String>> linesWeNeed(){ ArrayList<ArrayList<String>> returnListList = new ArrayList<ArrayList<String>>(); for(int i = 1; i<=45; i++){ int pageNum=(i*20)-20; System.out.println("PageNum"+pageNum); URL url=null; try { url = new URL("http://tq.mot.gov.il/index.php?option=com_moofaq&iotype=w&view=category&lang_ovrrde=ENG&id=3&Itemid=29&limitstart="+pageNum); } catch (MalformedURLException e) { System.out.println("Oh uh!"); } BufferedReader in = null; try { in = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8")); } catch (IOException e) { System.out.println("FATAL ERROR"); e.printStackTrace(); } ArrayList<String> lineCodes = new ArrayList<String>(); ArrayList<String> linesWeNeed = new ArrayList<String>(); String line; try { readLines: while((line=in.readLine())!=null){ if(line.contains("</tr></table></div></div></li></ul></div></div><br /></div>")){ break readLines; } lineCodes.add(line); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } for(int o = 1; o>=lineCodes.size(); o++){ String readLine = lineCodes.get(o-1); if(o>=297){ linesWeNeed.add(readLine); } } returnListList.add(linesWeNeed); } return returnListList; } There are no errors, but for some reason every list in the arraylist the methods return is empty. Why?
Thanks in advance!