Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

new File("c:\\%.txt").toURL().opeStream() throws IllegalArgumentException  RSS feed

 
prashant kumar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
new File("c:\\%.txt").toURL().openStream() throws IllegalArgumentException.
But opening inputstream thru FileInputStream opens input stream to read %.txt file.
use of character '%' seems to be the only exception. why?
 
Kenneth Reising
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried escaping the percentage symbol?
If that doesnt work, why not try a different file name?
 
Prashant, Kumar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Kenneth for your reply. I found out that it was problem due to decoding of file string by URLDecoder.decode() . Encoding the file string first (URLEncoder.encode()) and then making URL object works perfect. Substituting (escaping) "%" with "%25" also has the same result.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!