我有这个代码,
else if (e.getSource() == saveButton) {
Scanner scan;
String es = " ";
try {
int status = chooser.showSaveDialog(null);
if (status == JFileChooser.APPROVE_OPTION) {
File newImageName = chooser.getSelectedFile();
PrintWriter outFile = new PrintWriter(new FileWriter(newImageName));
outFile.print(drawing.typefile);
outFile.print(drawing.iname);
outFile.print(drawing.width);
outFile.print(es);
outFile.print(drawing.height);
outFile.print(drawing.maxshade);
for(int r = 0; r < drawing.array.length; r++)
for(int c = 0; c < drawing.array[r].length; c++)
outFile.print(drawing.array[r][c]);
// outFile.print(drawing.paintComponent(newImageName));
outFile.flush();
outFile.close();
}
else if (status == JFileChooser.CANCEL_OPTION) {
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "File could not be written, try again.");
//ex.printStackTrace();
}
}
以及如何让它在值之间打印空格?它打印
P2image1.pgm320 275255132132130125125128
我需要它来打印
P2image1.pgm320 275255132 132 130 125 125 128
因此每个数组值之间都有一个空格,我尝试了很多东西,但我完全糊涂了。
谢谢。