如何在方法中将行添加到TXT文件中?

时间:2017-03-08 18:32:36

标签: java file

如何使用引号在SELECT Service, COUNT (DISTINCT CustAccount) AS Customers_count, COUNT (distinct CASE WHEN Charge = 'SE' THEN CustAccount END) AS SE_charges FROM MyTable GROUP BY Service 括号内的void txt()括号内打印driver.get()方法中绘制的txt文件中的行?

我想从txt文件中获取一个链接,让自动程序进入该站点。

感谢您的帮助。

void link()

1 个答案:

答案 0 :(得分:0)

将您提到的以下方法更改为逐行读取文件直到EOF。

 public void txt() throws IOException {

        // open the LinkAl txt file
        File file = new File("LinkAl.txt");
        String line="";
        BufferedReader reader = null;
        reader = new BufferedReader(new FileReader(file));
        while ((line = reader.readLine()) != null) {

                    // System.out.println(line);
                       link(line);

            }
        }   

此外,如果您想将读取行传递给链接方法,请将其更改为

public void link(String line) throws InterruptedException { 

          System.out.println("Dosyadançekilenlerveriler: " + line);

            // driver.get("https://www.google.com/");
           driver.get(line);
             Thread.sleep(3000);     
        }