• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

How to create a file in specified directory

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am trying to create a file in a directory in append mode.Its not getting creayed.here is the code.Can you please help me.
FileWriter fNew = new FileWriter("C:/xml/newXML.xml,true);
i am able to create a file directly under c:/ like
FileWriter fNew = new FileWriter("C:/newXML.xml,true);
when i try to create in xml directory which is already exists under c its giving an exception.

Regards
Kiran
[ December 01, 2003: Message edited by: Kiran Baratam ]
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the exception and contents of the stack trace?
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kiran,
When creating a file you will have to make sure that the directory under which the file has to be created exsist. In your particular case you can use following code

Also, don't forget to 'escape' the forward/backward slash.
HTH
Ashish
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ashish Gupta:
Kiran,
When creating a file you will have to make sure that the directory under which the file has to be created exsist.


She states that the directory does exist.


Also, don't forget to 'escape' the forward/backward slash.


Forward-leaning slashes, like those used in Unux paths, do not need to be escaped and also work fine in Windows.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic