여기에 도움이 필요합니다.
FileOutputStream을 사용하여 파일에 바이트를 쓰려고합니다.
파일은 내가 만든 jar 파일처럼 디렉토리에 나타나지 않습니다.
다른 방법으로 시도해도 파일을 플러시하는 경우에도 파일에 아무 것도 쓰지 않습니다.FileOutputStream이 파일에 쓰거나 파일을 생성하지 못했습니다.
여기에 내 현재 코드는 다음과 같습니다
File ModFile =new File(NameText.getText() + ".mod");
FileOutputStream writer = null;
String toProcess = CodesBox.getText();
int i = Integer.parseInt(CodesBox.getText());
byte codes = (byte) i;
try {
writer = new FileOutputStream(ModFile);
writer.write(codes);
} catch (IOException ex) {
Logger.getLogger(ModMakerGui.class.getName()).log(Level.SEVERE, null, ex);
}finally{
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
이 도와주세요!
'ModFile'의 경로는 무엇이며 실행 파일은 어디에 있습니까? – jlordo
1.이 코드가 실제로 실행되고 있습니까? 2. 실행중인 경우 현재 작업 디렉토리는 무엇입니까? –
['File.getAbsolutePath()']를 사용하여 실제로 파일을 만들 위치를 확인할 수 있습니다 (http://docs.oracle.com/javase/1.4.2/docs/api/java/io/File.html# getAbsolutePath % 28 % 29). – JimmyB