Saturday, August 2, 2008

Program to create a new file

Source code to create a new file:


package com.milestone.snippets;

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

/**
* @author AARYA
*
*/
public class CodeSnippetTester
{
/**
* @param args
*/
public static void main(String[] args)
{
try
{
File file = new File("addressbook.txt");
boolean success = file.createNewFile();
if (success)
{
System.out.println("New File Created");
} else
{
System.out.println("File Already Exists");
}
} catch (IOException e)
{
}
}
}

0 comments: