How to create new file in Java?

Below is the java code to create a new file using java.io.Java class

[java]
/****************************************************************************************
* Created on 08-2011 Copyright(c) https://kodehelp.com All Rights Reserved.
****************************************************************************************/
package com.kodehelp.java.io;

import java.io.File;
import java.io.IOException;

/**
* Created by Vigilance India.
* User: https://kodehelp.com
* Date: Aug 4, 2011
*/
public class CreateNewFile {
public static void main(String args[]){
try{
File file = new File("/demo.txt");
if(file.createNewFile()){
System.out.println("New File Created");
}else{
System.out.println("File already exists");
}
}catch(IOException ex){
ex.printStackTrace();
}
}
}

[/java]