为什么我得到'未报告的期望FileNotFoundException;必须被抓住或宣布被扔进我的程序?

时间:2014-04-26 11:58:28

标签: java

我不知道为什么我得到了一个未报告的期望FileNotFoundException;必须被抓住或宣布被扔掉#39;消息和'非法开始的类型。包阅读器不存在。预期';'预期'我的程序中的消息?

import java.io.File;
import java.util.Scanner;

public class TelephoneDirectory { 
    String name; 
    String telnumber; 
    private String sourceName;
    private int size;
    private DirectoryEntry[] theDirectory;
    /** 
    * 
    * @param name a person's name 
    * @param telno a person's telephone number 
    */ 
    public TelephoneDirectory(String name, String telno){ 
        this.name = name; 
        this.telnumber = telno; 
    }
    public String getName()
    {
        return this.name;
    }
    public String getNumber(){ 
        return telnumber; 
    }
    public void setNumber(String newTelno)
    {
    this.telnumber = newTelno;
    }
    @Override 
    public String toString()
    {
        return ("[Name = " + this.name + ", " + "Number = " + this.telnumber + "]");
    }
    public String format()
    {
        return String.format("The number for %-1s is %-1s \r\n",  this.getName(), this.getNumber());
    }

    private static class DirectoryEntry {

        public DirectoryEntry() {
        }

        private DirectoryEntry(String name, String telnumber) {
            throw new UnsupportedOperationException("Not yet implemented");
        }
    }

    private static class telno {
        private static String txt;

        public telno() {
        }
    }

    public interface PhoneDirectory 
    { 
        /** Load file containing directory entries 
        @param sourceName is name of the file containing 
        the directory entries 
        */ 
        void loadData(String sourceName); 

        /** Look up an entry. 
        @param name The name of person to look up 
        @return The telnumber or null if name is not in the directory 
        */ 
        String lookUpEntry(String name); 

        /** Add new entry or change an existing entry. 
        @param name The name of the person being added 
        or whose telnumber is going to change 
        @param telno The telnumber being changed or added 
        @return The old telnumber or if a new entry null 
        */ 
        String addChangeEntry(String name, String telno); 

        /** Remove an entry from the directory. 
        @param name The name of the person to be removed 
        @return The current telnumber. If not in the directory, null is 
        returned. 
        */ 
        String removeEntry(String name); 

        /** If the directory has been modified the contents 
        of the directory are written back to the file 
        */ 
        void save(); 

        /** 
        * Builds a single string representing directory contents 
        * Each entry is terminated by a new line 
        * @return The formatted list of directory contents 
        */ 
        String format(); 
    }
    Scanner reader = new Scanner(new File(telno.txt));

    while(reader.hasNext())
    {
        String name = reader.nextLine();
        String telno = reader.nextLine();

        this.theDirectory[this.size] = new  DirectoryEntry(name, telnumber);

        this.size++;
        return null;
    }
    public class ArrayPhoneDirectory implements PhoneDirectory 
    { 
    private static final int INIT_CAPACITY = 100; 
    private final int capacity = INIT_CAPACITY; 

    // holds telno of directory entries 

    private final int size = 0; 


    public final DirectoryEntry[] theDirectory = new DirectoryEntry[capacity]; 

    // Holds name of data file 

    private final String sourceName = telno.txt; 

    // Flag to indicate whether directory was modified since it was last loaded or saved 

    private final boolean modified = false; 

    // add method stubs as specified in interface to compile 

    // add private methods 

        @Override
        public void loadData(String sourceName) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public String lookUpEntry(String name) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public String addChangeEntry(String name, String telno) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public String removeEntry(String name) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void save() {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public String format() {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    }
}

我不明白为什么会收到这些错误消息

0 个答案:

没有答案