/* program for finding the absolute path of the file */
import java.io.*;
class getPathOfFile
{
public static void main(String[] args)
{
try
{
File f=new File("NewFile.txt");
if(!f.exists())
{
f.createNewFile();
System.out.println("New File created...");
System.out.println("Its absolute path is : "+f.getAbsolutePath());
}
else
{
System.out.println("File already exists...");
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}
import java.io.*;
class getPathOfFile
{
public static void main(String[] args)
{
try
{
File f=new File("NewFile.txt");
if(!f.exists())
{
f.createNewFile();
System.out.println("New File created...");
System.out.println("Its absolute path is : "+f.getAbsolutePath());
}
else
{
System.out.println("File already exists...");
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}
Output
New File created...
Its absolute path is : E:\Java_NetBeans\PROGRAMMING\JavaIO\NewFile.txt
No comments:
Post a Comment