0

ファイルを読み取って特定のフォルダーに書き込もうとしています。私はこのコードを使用しています:

private void saveFile(File file){
    try {
        OutputStream out = new FileOutputStream(new File("/Users/default/Desktop/fotos/test.png"));
        Files.copy(file.toPath(), out);
                System.exit(0);

    } catch (IOException ex) {
        Logger.getLogger(GetFiles.class.getName()).log(Level.SEVERE, null, ex);
    }
}

ファイルは .png ファイルです。この方法を使用すると、fotos ディレクトリに新しい .png が作成されますが、ダブルクリックすると空であると表示されます。これはどのように可能で、どうすれば解決できますか?

4

1 に答える 1