현재 내가 만든 Java 게임의 레벨 편집기를 만들려고합니다.
내 문제는 내 프로그램이 편집 된 수준을 저장하지 않는다는 것입니다.닫으려고 할 때 FileSystem 오류가 발생했습니다.
Path path = Paths.get(gameFile.getAbsolutePath());
FileSystem fs = FileSystems.newFileSystem(path, null);
Path p = fs.getPath("rpg"+fs.getSeparator()+"levels"+fs.getSeparator()+"level"+(short)level+".png");
OutputStream os = Files.newOutputStream(p);
ImageIO.write(img, "png", os);
os.close();
fs.close();
gameFile
가 .png 파일로 저장하는 수준과 수준을 포함 내 게임의 .jar 파일입니다 : 여기
항아리 밖에서 사진을 저장하려고 시도 했으므로 FileSystem이나 Path를 사용하여 실수를 저지른 것 같습니다.
항아리의 경로
편집 .png를 롤 플레잉/레벨/레벨 *입니다 :
내가
OutputStream os = Files.newOutputStream(p);
변경에
OutputStream os = Files.newOutputStream(p,StandardOpenOption.CREATE,StandardOpenOption.TRUNCATE_EXISTING);
을하지만 닫을 때 지금은 오류가 파일 시스템
java.nio.file.FileSystemException: G:\RPG.jar: The process cannot access the file because it is being used by another process.
at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
at sun.nio.fs.AbstractFileSystemProvider.delete(Unknown Source)
at java.nio.file.Files.delete(Unknown Source)
at com.sun.nio.zipfs.ZipFileSystem.sync(ZipFileSystem.java:1294)
at com.sun.nio.zipfs.ZipFileSystem.close(ZipFileSystem.java:277)
at de.jorolf.editor.LevelEditor$5.actionPerformed(LevelEditor.java:213)
또한 ** 동의하시기 바랍니다 ** 그의 대답은 ([답변 수락 : 어떻게 작동합니까?] (https : //로 메타 .stackexchange.com/questions/5234/how-does-accepting-an-answer-work)). 답변을 얻지 못했다면 StackOverflow의 중요한 부분입니다. 정말 고마워요. – Zabuza