0

I want to download only the last line displayed on the server to my android device. Can you please tell me the process or give a basic idea. I am trying to download files and then compare. But cant we do by just fetching the last line.

                   try { 
                    BufferedReader br1 = new BufferedReader(new FileReader(file1));
                    BufferedReader br2 = new BufferedReader(new FileReader(file2));


                    String strLine1, strLine2;
                    boolean isSame = true;
                    StringBuilder finalText = new StringBuilder();
                    strLine1 = br1.readLine();
                    strLine2 = br2.readLine();
                    if (strLine1.equals(strLine2))
                        Toast.makeText(getBaseContext(), strLine2,
                                Toast.LENGTH_LONG).show();
                    else {
                        isSame = false;
                        Toast.makeText(getBaseContext(), strLine1,
                                Toast.LENGTH_LONG).show();
                        tv.setText(finalText.toString());


                    }
                }finally{
                }
4

1 回答 1

0

我认为应该有循环

 String thisLine ="";   
    String line="";
         while ((thisLine = br.readLine()) != null) { // while loop begins here
                 System.out.println(thisLine);
                  // line = line + thisLine ;
                     line = thisLine ;
               } //
于 2012-06-23T11:41:00.053 回答