Код: Выделить всё
.txt
Он выдает исключение FileNotFoundException.
Я безуспешно пытался сохранить файл несколькими способами.
Код: Выделить всё
public static boolean saveFile(File sourceFile) throws IOException {
DirectoryChooserDialog dialog = new DirectoryChooserDialog();
filePath = dialog.getDestinationFolder();
if (filePath != null) {
InputStream inputFile = ClassLoader.getSystemResourceAsStream(""+sourceFile);
filePath += File.separator + sourceFile.getName();
FileOutputStream outputFile = new FileOutputStream(filePath);
int byteLetti = 0;
while ((byteLetti = inputFile.read(buffer)) >= 0) {
outputFile.write(buffer, 0, byteLetti);
outputFile.flush();
}
inputFile.close();
outputFile.close();
return true;
} else
return false;
}
Код: Выделить всё
FileInputStream inputFile = new FileInputStream(sourceFile);
Код: Выделить всё
InputStream inputFile = ClassLoader.class.getResourceAsStream(""+sourceFile);
Код: Выделить всё
InputStream inputFile = FileSaving.class.getResourceAsStream(""+sourceFile);
Подробнее здесь: https://stackoverflow.com/questions/120 ... in-eclipse