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 :)
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];
File fileOut = new File (path,text);
DataOutputStream thefileOut = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(fileOut)));
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.