Выходные данные Java inputtreamreader не соответствуют данным в URL? - PullRequest
0 голосов
/ 13 января 2019
//Will read the contents of a txt file (one integer per line) and print to 
//console
import java.net.*;
import java.io.*;


public class WebPagesStats {

public static void main(String[] args) throws IOException {
    try {   //find my website and the txt file
        URL mySite = new URL("http://sites.google.com/site/"
                + "stephenkofflercodingprojects/"
                + "files-to-download/CBS%2020181223%20PAGEVIEWS.TXT");
        URLConnection myConnection = mySite.openConnection();   //open 
        connection
        InputStream input = myConnection.getInputStream();  //get 
        inputStream

        BufferedReader in;  // For reading from the connection's input 
         stream.
         in = new BufferedReader( new InputStreamReader(input) );


         while(in.read() != -1 )  {


             System.out.println(in.read()); //Print each line of 
          BufferedReader
         }
        } 
    catch (IOException e) {//IO Exception if file not found

        e.printStackTrace();
    }
    }

//output has numbers on each line, but not the ones in the file.
}//end

// сравнение первых 4 строк

OUTPUT
13

50

10

49

CBS 20181223 PageViews.txt

1

2

11

4

Что еще я могу добавить сюда, чтобы принять вопрос? Я прокомментировал почти каждую строку. Я просто напечатал поток сознания, чтобы система приняла мой вопрос !!!! Я очень старался понять это, ссылаясь на несколько учебников, спрашивая моего профессора, других моих знакомых, преподавателя Java, с которым я работал. Все в тупик. Я действительно не понимаю критерии для постановки «хороших» вопросов

...