Menu

[solved] – Question 708

I need to create a file in java. However there’s errors in my output. Could you please help me out?
import java.io.*;
/**
* Write a description of class CreateFile1 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class CreateFile1
{
public static void main(String[] args)throws IOException
{
File f;
f=new File(“C:MyFile.txt”);
if(!f.exists()){
f.createNewFile();
System.out.println(“New file”+ “C:MyFile.txt”+” has been created to the current directory”);
}
}
}

Expert Answer


OR


Leave a Reply

Your email address will not be published. Required fields are marked *