开发者

Importing Contacts in to an address book GUI from a file using BufferedWriter method

开发者 https://www.devze.com 2022-12-12 22:57 出处:网络
Here you can see ive used the BufferedReader method to impotr contacts from an external file, but i keep getting the repeated errors -

Here you can see ive used the BufferedReader method to impotr contacts from an external file, but i keep getting the repeated errors -

not a statement, illegal start of expression and ';' expected.

can anybody help?

 public void importContacts(){

    try{
        BufferedReader import = new BufferedReader(new FileReader("example.buab"));
        int i = 0;
        String contacts;
        while (( contacts = import.readLine()) != null)
        {
             temp.add(contacts);
   开发者_JS百科          i++;
        }
        int a = 0;
        int b = 0;
        for (a = 0, b = 0; a < temp.size(); a++, b++) 
        {
        if (b == 4)
        {
            b = 0;
        }
        if (b == 0)
        {
            Name.add(temp.get(a));
        }
        if (b == 1)
        {
            Phone.add(temp.get(a));
        }
        if (b == 2)
        {
            Mobile.add(temp.get(a));
        }
        if (b == 3)
        {
            Address.add(temp.get(a));       
        }         
        } 
        }
        catch (IOException ioe)               
         {                       
             ioe.printStackTrace();                
         }                
             txtname.setText(Name.get(0));                
             txtnum.setText(Phone.get(0));               
             txtmob.setText(Mobile.get(0));               
             txtadd1.setText(Address.get(0));
        }


Your BufferedReader variable is called import, and that's a reserved word - you can't use it for variables.

0

精彩评论

暂无评论...
验证码 换一张
取 消