• Post Reply Bookmark Topic Watch Topic
  • New Topic

help with file deletion..please help..  RSS feed

 
karan, chopra
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i have a servlet which writes something to a text file(say filename.txt).i want that whenever the servlet is executed again then it should delete the already existing filename.txt and create a new one.how can this be done..please help..its urgent..(i tried File.delete() but it throws some weird exception and doesnt let me delete the file)...
PS-can file deletion be done from an applet?
thanks a ton
regards
karan
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exception is being thrown?
Originally posted by karan, chopra:
hi all,
i have a servlet which writes something to a text file(say filename.txt).i want that whenever the servlet is executed again then it should delete the already existing filename.txt and create a new one.how can this be done..please help..its urgent..(i tried File.delete() but it throws some weird exception and doesnt let me delete the file)...
PS-can file deletion be done from an applet?
thanks a ton
regards
karan

 
karan, chopra
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi matt,
i wrote the following code for deleting the file in my servlet and it gave me the following exception in my applet.
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
res.setContentType("text/html");

File name = new File("/","node.txt");
if(name.exists() && name.isFile())
{
name .delete();
}

File name1 = new File("/","link.txt");
if(name1.exists() && name1.isFile())
{
name1 .delete();
}

File name2 = new File("/","incident.txt");
if(name2.exists() && name2.isFile())
{
name2 .delete();
}


FileWriter fw = new FileWriter("dir path" + "node.txt", true);
BufferedWriter bw = new BufferedWriter(fw);

FileWriter fw1 = new FileWriter("dir path" + "link.txt", true);
BufferedWriter bw1 = new BufferedWriter(fw1);

FileWriter fw2 = new FileWriter("dir path" + "incident.txt", true);
BufferedWriter bw2 = new BufferedWriter(fw2);
now i write the 3 files
}
this is the exception
java.lang.NumberFormatException: multiple points
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1036)
at java.lang.Double.valueOf(Double.java:168)
at Simple.drawPoint_database(Simple.java:461)
at Simple.paint(Simple.java:715)
at javax.swing.JApplet.update(JApplet.java:133)
at sun.awt.RepaintArea.update(RepaintArea.java:337)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:197)
at java.awt.Component.dispatchEventImpl(Component.java:2665)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
simu
java.lang.NumberFormatException: multiple points
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1036)
at java.lang.Double.valueOf(Double.java:168)
at Simple.drawlink_database(Simple.java:536)
at Simple.paint(Simple.java:731)
at javax.swing.JApplet.update(JApplet.java:133)
at sun.awt.RepaintArea.update(RepaintArea.java:337)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:197)
at java.awt.Component.dispatchEventImpl(Component.java:2665)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
basically when i execute my applet,it communicates with the servlet which in turn generates 3 output files which are then read by the applet.but i want them to be new files when the applet reads them.but as i menitioned above.it is not working.
any suggestions?
thanks in advance
regards
karan
 
Ryan Langley
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I don't think this exception has anything to do with what you are trying to do with the files. NumberFormatException indicates that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format. You aren't doing this with any of the code you have displayed here. It looks like it is happening under the Simple classes paint method somewhere.
------------------
Cheers,
RL
[This message has been edited by Ryan Langley (edited June 14, 2001).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!