1

I got some problems with my Code

window.videoInfo.addActionListener(new ActionListener() {

    public void actionPerformed(ActionEvent e) {

     try {

     URL url = new URL(window.videoInput.getText());
     URLConnection con = url.openConnection();

   LineNumberReader in = new LineNumberReader(new InputStreamReader(con.getInputStream()));
   in.setLineNumber(1523);
   in.getLineNumber();

      System.out.print(in.readLine());

     } catch (IOException ex) {
        ex.printStackTrace(); 

     }

I am trying to display a specific Line from a website. But if i press the button it always displays the first line. Even when i set the line Number to 1523.

4

1 回答 1

1

setLineNumber(1523)只使返回的行号getLineNumber()1523. 它不会跳过 1523 行。要跳过 1523 行,您需要执行以下操作:

for(int i = 0; i < 1523; i++)
    in.readLine();
于 2013-05-18T12:00:36.813 回答