Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query on StreamResult object for storing transformed xml doc

 
Colm Dickson
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,


I was puzzled recently as to why the code I had was throwing an IO FileNotFound error when I had



but worked when I simply used




There is a constructor for Streamresult that takes a File object which I though was correct in the first example. can someone explain what is happeneing here. I would have expected the file to be created with the transformed data in my C drive using example one ...Also , would it be right to say that the second example which works is using the constructor for StrreamResult that takes a string (Construct a StreamResult from a URL.)...becasue such a constructor exists?


Thanks

 
Paul Clapham
Sheriff
Posts: 21137
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That second example is surely the constructor which expects a URL in String form. What you posted there isn't a URL, so I'm surprised that it worked. I'm also surprised that the first example didn't. My conclusion from all of that is that you have got your tests backwards; the first example should work (assuming that file exists) and the second should not.
 
Colm Dickson
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying.

Yes it's strange and I checked again and the new File argument does indeed fail and the String URL one works and creates a file with that name in my project directory yet specifying new File("C:\\filename") causes an IO error and this location is fully writable.


Trying this method below however does work




Colm
 
g tsuji
Ranch Hand
Posts: 667
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're still using jdk 1.3.1 or about, you should consider update jdk. There was a bug on 1.3.1 for constructor StreamResult(File).
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5052510
It should have been fixed in 1.5 or higher.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic