Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class WriteFile {
- public static void main(String[] args) {
- Path path = Paths.get("C:\\Users\\Jordy\\OneDrive\\Eclipse Workspace\\Java Advanced H5 Lezen en schrijven IO\\newFile.txt");
- try(BufferedWriter writer = Files.newBufferedWriter(path)) {
- writer.write("This is some text again", 0, 4);
- writer.newLine();
- writer.write("This is another text",0,15);
- File bestand = path.toFile();
- bestand.setReadOnly();
- }
- catch (IOException ex) {
- System.out.println("Problem with writing");
- System.out.println(ex.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement