本文介绍了行号读取器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码有问题

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();

     }

我正在尝试显示来自网站的特定行.但是如果我按下按钮,它总是显示第一行.即使我将行号设置为 1523.

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.

推荐答案

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

setLineNumber(1523) only makes the line number returned by getLineNumber() starts with 1523. It won't skip 1523 lines. To skip 1523 lines, you need to do:

for(int i = 0; i < 1523; i++)
    in.readLine();

这篇关于行号读取器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 03:12