Create a new file and save byte array
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
public class Test {
public static void main(String[] args) throws IOException {
Path path = Paths.get("/users.txt");
byte[] contents = Files.readAllBytes(path);
Path newPath = Paths.get("/newUsers.txt");
Files.write(newPath, contents, StandardOpenOption.CREATE);
}
}
Related examples in the same category