Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 5th, 2007, 02:02 AM
Authorized User
Join Date: Sep 2006
Location: , , .
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default Delete file from folder using FileOutputStream

This is Kotaiah,

How to delete file from folder using FileOutputStream?

Please let me know ASAP

L&T Infotech,Pune

Reply With Quote
  #2 (permalink)  
Old March 8th, 2007, 04:47 AM
Authorized User
Join Date: Feb 2005
Location: chch, n/a, New Zealand.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts

quote:How to delete file from folder using FileOutputStream?

Please let me know ASAP
Okay here is some code from my program (having trouble with writing to and reading from a file but that's nothing to do with your problem :)

import java.io.*;

public class mysimpleio
  String thefilename = "";

  DataOutputStream thefileOut = null;
  DataInputStream thefileIn = null;

  public static void main(String[] args)
    String text = "";
    String path = "e:\\my_project\\crm\\";
    if (args.length == 0)
        System.out.println("No file name, Exiting program!");
    if (args.length > 0)
        for (int i=0; i < args.length; i++)
          text = text + args[i];

          System.out.print (path);

         File fileOut = new File (path,text);

          DataOutputStream thefileOut = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(fileOut)));

          if (fileOut.exists())
        catch(IOException e)
         System.out.print("Error occured!"+ e);
it is the TRY bit ~10 lines up that's important to you!!

I've put in the code down to the end of the TRY block so you can see what i've done and how it relates to the fileOut.delete() action.



Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to delete file System.IO.Delete error maricar C# 13 March 14th, 2014 06:50 AM
How to delete folder with php tinhbanghuu PHP How-To 4 March 26th, 2008 02:59 AM
Can Global.asa be used to delete a folder. solos Classic ASP Basics 9 February 13th, 2007 06:05 PM
Rename File/Folder shivanshub General .NET 0 August 11th, 2006 01:57 PM
JSP file upload and delete file pandjie JSP Basics 0 January 29th, 2005 10:49 PM

All times are GMT -4. The time now is 06:16 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.