Using Files class:
- import java.nio.file.Files;
- import java.nio.file.Paths;
- import java.nio.file.Path;
- import java.io.IOException;
- public class WriteByFiles {
- public static void main(String[] args) throws IOException {
- String content = "writing data to data1.txt file using Files class !!";
- String uri = "D:\\data1.txt";
- Path path = Paths.get(uri);
- Files.write(path, content.getBytes());
- }
- }
writing data to data1.txt file using Files class !!
No comments:
Post a Comment