Create New file

There are 3 ways to create a new file in Java 1) Using java.io.File.createNewFile() method 2) Using java.io.FileOutputStream class 3) Using java.nio.file.Files from NIO API 1) Using java.io.File.createNewFile() method File file = new File("C:\\newfile1.txt");   //Creates new file and return true if file not exists and return false if file already exists boolean fvar = […]

Share this article on

File I/O Overview

I/O stands for input and output Java provides several APIs to perform input and output operations and all these APIs are bundled in a package called “java.io” package. Input means reading data from a source Example: Reading data from a file Reading data from keyboard output means writing data to the destination. Example: Writing data […]

Share this article on
< Previous Next >