Friday, 11 November 2016

Java Tutorial : Java IO (Java File - How to create a file)

Click here to watch in Youtube :

 *  Create a new file.
public class FileDemo

    public static void main(String[] args) throws IOException
        File file = new File("D:/work/myfile.txt");

         * Atomically creates a new, empty file named by
         * this abstract pathname if and only if a file with
         * this name does not yet exist.
         * Returns: true if the named file does not exist
         * and was successfully created; false if the named
         * file already exists
        if (file.createNewFile())
            System.out.println("File is created!");
            System.out.println("File already exists.");

File is created!

Click the below link to download the code:

Github Link:

Bitbucket Link:

See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge