How to delete a file with java (see mine code)-VBForums
Results 1 to 2 of 2

Thread: How to delete a file with java (see mine code)

Hybrid View

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2012

    How to delete a file with java (see mine code)

    This program should delete cookedBooks.txt, but it doesnt. I created cookedBooks.txt in a folder. Can somebody push me in the right directions.

    import static java.lang.System.out;
    import java.util.Scanner;
    class DeleteEvidence {
    	public static void main(String[] args) {
    		File evidence = new File("cookedBooks.txt");
    		Scanner keyboard = new Scanner(;
    		char reply;
    		do	{
    			System.out.println("Delete Evidence? (Y/N) ");
    			reply = 
    		} while (reply != 'y' && reply != 'n');
    		if (reply == 'y') {
    			System.out.println("here we go");
    		System.out.println("Has been deleted");

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Adelaide, Australia

    Re: How to delete a file with java (see mine code)

    You need to place the file to be deleted in the main project folder outside the "src" folder.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    Please consider giving me some rep points if I help you a lot.
    Please rate my post if you find it helpful!
    Technology is a dangerous thing in the hands of an idiot! I am that idiot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width