0

このエラーが発生し続けます。目標は、配列から出力ファイルにデータを読み取ることです。助けてくれてありがとう!

public static void save(Salesperson[] array)

  {
     PrintStream outfile = null;
     try
     {
        outfile = new PrintStream(new FileOutputStream("data.txt"));
     }
        catch(FileNotFoundException e)
        {
           JOptionPane.showMessageDialog(null,"The file could not be created.");
        }
         System.setOut(new PrintStream(new FileOutputStream("output.txt")));
     for(int k = 0; k < array.length; k++)
     {
        System.out.println(array[k]);
     }

     outfile.close();
     System.out.println("Saved.");

  }
4

1 に答える 1