Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
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:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
FileNotFoundException error
Jamie Wool
Ranch Hand
Posts: 49
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I'm using Netbeans 2.6 and am having a problem with writing to a file. I can read from the file fine with the below code:
try{ [B] f = new File(this.getClass().getResource("/FrontEnd/BackEnd/XML Data/").getFile(), fileName);[/B] doc = builder.parse(f); Element root = doc.getDocumentElement(); array = getItems(root, tagname, array); }catch (IOException ioe) { balh blah }
but i'm trying to write to the identicle file with this code
tagname = "customers"; filename = "customers.xml"; ListBuilder cubuilder = new ListBuilder(); Document cudoc = cubuilder.build(tagname, customers); try{ t = TransformerFactory.newInstance().newTransformer(); } catch (Exception e){ System.out.println("Error creating Transformer"+ e); } try{ [B]t.transform(new DOMSource(cudoc), new StreamResult(this.getClass().getResource("/FrontEnd/BackEnd/XML Data/" + filename).getFile()));[/B] } catch (Exception e){ System.out.println("Error creating customers.xml file from doc"+ e); } But it gives me this error [CODE] Error creating customers.xml file from docjavax.xml.transform.TransformerException: java.io.FileNotFoundException: C:\Documents%20and%20Settings\James\Desktop\java\Design\FrontEnd\BackEnd\XML Data\customers.xml (The system cannot find the path specified)
I'm confused as the code was copied from the first part, it uses the same file and it deffinately exists.
Can anyone please help?
Kareem Qureshi
Ranch Hand
Posts: 102
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
This can also happen when an attempt is made to open a read-only file for writing.
Hope this helps.
Thanks
Kareem
First, you drop a couch from the plane, THEN you surf it. Here, take this tiny ad with you:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
jEditorPane clearing cache
reading the xml files thru java
Lucene beginner question
writing back to jar file ??
Incorrect paths in Netbeans
More...