|
check wheather path is like this....."
c:\\directoryname\\fiename "
zulfi Keep Smiling. It does improve your face value. :-)
----- Original Message -----
Sent: Thursday, April 20, 2000 5:02
PM
Subject: Re: Renaming file
Does
it give a runtime error or a compile error?
If
it is a compile error it may be due to the path seperator
'\'.
Use
:
String
sep=System.getProperty("file.seperator");
The
use the file path as:
String
path="c:"+sep+"directory"+sep+"hello.txt";
Dave.
Hi,
I am attaching a code down where I am renaming file. it
works fine if I am not giving the path but when I include path its
giving error can somebody help me out in this
David
import
java.io.*;
import java.util.*;
public class test
{
public static void
main(String args[])
{
try
{
File fil= new File("hello.txt");
if( fil.exists () )
System.out.println( "Exists");
if( fil.renameTo(new
File("hello1.txt")) )
System.out.println( "Succeeded");
else
System.out.println( "Failed");
}
catch(Exception e){}
}
}
|