// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;

public class Files17 {
    public static void main(String[] args) throws IOException {
        Path from = Paths.get("java17.txt");
        Path to = Paths.get("z.txt");
        // binary
        Files.write(to, Files.readAllBytes(from));
        Files.delete(to);
        // text
        Files.write(to, Files.readAllLines(from, Charset.forName("ISO-8859-1")), Charset.forName("ISO-8859-1"));
        Files.delete(to);
        // lazy
        Files.copy(from, to);
        Files.delete(to);
    }
}
