*
The moose likes Java in General and the fly likes escaped absolute path not valid Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "escaped absolute path not valid" Watch "escaped absolute path not valid" New topic
Author

escaped absolute path not valid

saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

Did you try to enclose the path with double quotations ?


[My Blog]
All roads lead to JavaRanch
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
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

Joined: Sep 08, 2007
Posts: 3064
    
  33

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.


Mohamed Sanaulla | My Blog
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
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

Joined: Sep 08, 2007
Posts: 3064
    
  33

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

Joined: Dec 02, 2009
Posts: 159
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

Joined: Sep 08, 2007
Posts: 3064
    
  33

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

Joined: Dec 02, 2009
Posts: 159
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

Joined: Sep 08, 2007
Posts: 3064
    
  33

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

Joined: Dec 02, 2009
Posts: 159
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

Joined: Sep 08, 2007
Posts: 3064
    
  33

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

Joined: Dec 02, 2009
Posts: 159
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

Joined: Dec 02, 2009
Posts: 159
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.
 
 
subject: escaped absolute path not valid
 
Similar Threads
Configuring the SOAP Header in client
problem with PATH and PATH variables
problem with jess!!!
Accessing files in NetBeans
url with a space giving problem