Lidon Sianturi’s Blog


Deleting MUltiply File USing Java
November 23, 2008, 4:33 am
Filed under: Programming

Deleting File Using Java…

import java.io.*;
public class DeleteFile{
private static void deletefile(String file){
File f1 = new File(file);
boolean success = f1.delete();

if (!success){
System.out.println(”Deletion failed.”);
System.exit(0);
}
else{
System.out.println(”File deleted.”);
}
}
public static void main(String[] args){
switch(args.length){
case 0: System.out.println(”File has not mentioned.”);
System.exit(0);
case 1: deletefile(args[0]);
System.exit(0);
default : System.out.println(”Multiple files are not allow.”);
System.exit(0);
}
}
}

Advertisement

Leave a Comment so far
Leave a comment



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s



Follow

Get every new post delivered to your Inbox.