I have some Java code that takes a String and converts a space
to a +
. But when my programs reads that String back, it converts the +
to a %20
.
Is there any way for me to keep it consistent so that it:
- Either converts the
space
straight to%20
, OR - Doesn
t convert the
+to
%20`
Here`s what my code looks like:
import java.net.URLEncoder;
...
String fileNameEncoded = URLEncoder.encode(filename);
So if filename
was foo bar.html
, first pass would give me foo+bar.html
and second pass would give me foo%20bar.html
.