我正在嘗試讀取一個文件並打印出每行的子字符串。我無法弄清楚我的錯誤是什麼。我的鏈接有效,那麼導致錯誤的原因是什麼?java.io.FileNotFoundException,錯誤是什麼?
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
public class FileReader {
\t public void fileReader() {
\t \t File file = newFile("https://www.cs.uoregon.edu/Classes/14F/cis212/assignments/phonebook.txt");
\t \t try{
\t \t Scanner scan = new Scanner(file);
\t \t while(scan.hasNextLine())
\t \t {
\t \t \t String numAndName = scan.nextLine();
\t \t \t String newNum = numAndName.substring(0, 8);
\t \t \t System.out.println(newNum);
\t \t }
\t \t scan.close();
\t \t } catch(FileNotFoundException e)
\t \t \t {
\t \t \t \t e.printStackTrace();
\t \t \t }
\t }
}