Hi
Heres a sample class. May not be the best but I guess sure gives an idea.
File class has a lot of methods java doc would be of great help.
import java.io.File;
import java.io.IOException;
public class FileSys
{
public static void main(String s[]) throws IOException
{
/* Creates a new dir */
File file = new File( "hello" );
file.mkdirs();
/* Creates a new file */
file = new File( "hello" + File.separator + "hello.txt" );
file.createNewFile();
/* list files within dir */
file = new File( "hello" );
if( file.isDirectory() )
{
File dirStructure[] = file.listFiles();
for(int i=0; i<dirStructure.length; i++)
{
String name = dirStructure[i].getName();
System.out.println( name );
/* rename hello.txt to renamed.txt */
if( name.equals( "hello.txt" ) )
{
System.out.println( "Renaming to
renamed.txt" );
dirStructure[i].renameTo( new File(
"hello" + File.separator + "renamed.txt" ) );
}
}
}
/* deletes file or directory */
file.delete();
file = new File( "hello" );
file.delete();
}
}
Sincerely,
Jay
-----Original Message-----
From: Michael [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 28, 2002 8:50 AM
To: [EMAIL PROTECTED]
Subject: ot: filesystem-package/clases
<< File: ATT28620.txt >> Hi!
I know, it's a little bit OT!
but can anyone give me a hint how to create, rename, delete ... files and
directories in java!
thx
michi
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>