1
    private void view() throws IOException {
    // TODO Auto-generated method stub

    viewframe=new JFrame("#Customer Accounts#");
    viewframe.setSize(600,350);
    viewframe.setVisible(true);
    viewpanel=new JPanel(new BorderLayout());
    viewframe.add(viewpanel);

    int i=0;
    String data[][]=new String[100][100];
    String col[]={"Account Number","First Name", "Last Name", "Balance","Overdraft"};
    Boolean eof=false;
    try {
        datain=new DataInputStream(new FileInputStream("creditunion.txt"));

        while(!eof)
        {
            try{
                while(true)
                {
                    for(int j=0;j<=3;j++)
                    {
                        data[i][j]=datain.readUTF();
                    }
                    i++;
                }

            }catch(EOFException e)
            {
                eof=true;
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        datain.close();
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    viewtable=new JTable(data,col);
    scrollpane=new JScrollPane(viewtable);
    viewpanel.add(scrollpane);
}

 java.io.UTFDataFormatException: malformed input around byte 59
at java.io.DataInputStream.readUTF(Unknown Source)
at java.io.DataInputStream.readUTF(Unknown Source)
at CreditUnion.CreditUnion.view(CreditUnion.java:156)
at CreditUnion.CreditUnion.actionPerformed(CreditUnion.java:109)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

こんにちは、みんな。UTFDataFormatException が発生しましたが、原因がわかりません。問題なくtxtファイルにデータを書き込めるようで、ファイル自体にデータが表示されていることがわかります。

4

0 に答える 0