This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

escaped absolute path not valid

 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello every one,

I am not sure whether this is a proper place to post this topic.
Actually i am using PutMethod from apache http client, i am using to upload the files to my server, everything is going fine but if the file name contains a white space then it is throwing an Exception java.lang.IllegalArgumentException stating that

escaped absolute path not valid


Is there any way to overcome this.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try to enclose the path with double quotations ?
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But how can we achieve it because i use a browse button to select the file, so it will not be possible to enclose it with in a double quote.
So i am not sure about how to include so can you explain it how it can be achieved, b'coz when i tried in a stand-alone application with double quote adding to file in hard coded it is throwing file not found exception.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saipraneeth nallapareddy wrote:But how can we achieve it because i use a browse button to select the file, so it will not be possible to enclose it with in a double quote.
So i am not sure about how to include so can you explain it how it can be achieved, b'coz when i tried in a stand-alone application with double quote adding to file in hard coded it is throwing file not found exception.

You should be able to get the path before calling the method to upload the file, once you have access to the path String- You can always enclose it in quotes.
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please come up with the example because
mohamed sanaullah wrote: You should be able to get the path before calling the method to upload the file


This point is where i faced the problem and can you take a look the post i created facing the problem, if you can please give an example.
Now i am doing in a different way to get the path by using a temp dir, ofcourse this is not a good practice but i didn't had another option.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I went through the previous post. Can you tell us what changes you have made to it? Or if you are still facing the old issue- You could as well continue in the same thread- Why start a new thread. A new thread means a new context- So those who were helping in the old post would have more context to your problem.
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the context is different here because browsing for a full file path is now a not a problem for me b'coz i'm using a temp folder to get the uploaded file into it and using this path i am uploading.
Now the problem is with the white space in a file name, so i think this makes a sense why i choosed a new thread.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saipraneeth nallapareddy wrote:the context is different here because browsing for a full file path is now a not a problem for me b'coz i'm using a temp folder to get the uploaded file into it and using this path i am uploading.
Now the problem is with the white space in a file name, so i think this makes a sense why i choosed a new thread.


Can you show us the code which gets the File path?

And because you pointed to the other thread- thought you might be facing similar issue.
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought you know a process to get the path and you are asking me return.
This is the similar code that i used


mohamed sanaullah wrote: You should be able to get the path before calling the method to upload the file

how you are able to do.

Let me know how to add the double quote to the path
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know the process, but I wanted to know how you are doing it, so that I can tell you from your code context. And f.getAbsolutePath() returns you a String, and it should be easier to add quotes around this string.


 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mohamed sanaullah wrote:



In doing so and passing to the File it is recognizing the path but also adding the quote at the end.

but still i am facing the same error escaped absolute path not valid.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think this " " will work if you are passing it to the File object again- It will give you an exception. I might be going wayward- trying to fix- double quotes around the path- the solution might be different. And am not sure about it. But will this not work-



 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will get that string from a different method and i need pass to the file in order to create the stream.
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have solved it finally by using percentage encoding where space is replaced by %20.
thanks for those who replied me by going through the post and helped to solve the problem but finally i have solved the issue by myself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic