Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
Du speicherst dir den FileInputStream in keiner Variablen, damit hast du auch keine Möglichkeit den zu schließen.
public static void copyFile(File in, File out) throws IOException {
FileChannel inChannel = new FileInputStream(in).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
inChannel.transferTo(0, inChannel.size(), outChannel);
inChannel.close();
outChannel.close();
}
public static void copyFile(File in, File out) throws IOException {
FileInputStream fileInputStream = new FileInputStream(in);
FileOutputStream fileOutputStream = new FileOutputStream(out);
FileChannel inChannel = fileInputStream.getChannel();
FileChannel outChannel = fileOutputStream.getChannel();
inChannel.transferTo(0, inChannel.size(), outChannel);
fileInputStream.close();
fileOutputStream.close();
}
public static void copyFile(File in, File out) throws IOException {
try(FileInputStream fileInputStream = new FileInputStream(in);
FileOutputStream fileOutputStream = new FileOutputStream(out);
FileChannel inChannel = fileInputStream.getChannel();
FileChannel outChannel = fileOutputStream.getChannel();) {
inChannel.transferTo(0, inChannel.size(), outChannel);
}
}
public static void copyFile(File in, File out) throws IOException {
Files.copy( in.toPath(), out.toPath() );
}
public static void copyFile(File in, File out) throws IOException {
FileInputStream fileInputStream = new FileInputStream(in);
FileOutputStream fileOutputStream = new FileOutputStream(out);
FileChannel inChannel = fileInputStream.getChannel();
FileChannel outChannel = fileOutputStream.getChannel();
inChannel.transferTo(0, inChannel.size(), outChannel);
fileInputStream.close();
fileOutputStream.close();
out.setLastModified(in.lastModified());
}