0

I have programmed a class that get file with creating some parallel downloads. I use the simple code as below for any download :

DefaultHttpClient conn = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(new URI(M_url));
HttpResponse = conn.execute(httpPost);

In some file links (M_url) the program is okay, but when i want to download the link that contains the characters like [ ] URISyntaxException has occurred. For example, for the link http://dl.androidiha.com/games/Dead-Rider-v2.5.2[Androidiha.com].zip error is as below :

java.net.URISyntaxException: Illegal character in path at index 48: http://dl.androidiha.com/games/Dead-Rider-v2.5.2[Androidiha.com].zipException in thread "main" java.lang.NullPointerException

What is the programmatically solution for solve this problem? I use the following code, but this can't solve my problem :

M_url = URLEncoder.encode(M_url, "UTF-8")

Thanks in advance and sorry if this topic duplicates with similar one.

Hossein Mobasher
  • 4,382
  • 5
  • 46
  • 73

1 Answers1

1

I believe encoding maybe the answer. There is a similar topic existing on how to handle URISyntaxexception. How to deal with the URISyntaxException

I am sure you can solve the problem in a similar way

Community
  • 1
  • 1
Raveesh Sharma
  • 1,486
  • 5
  • 21
  • 38