Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Commit

Permalink
Files can now have spaces in their names on Android: #197
Browse files Browse the repository at this point in the history
  • Loading branch information
nikDemyankov committed Aug 30, 2016
1 parent 9796071 commit 87e0325
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/android/src/com/nordnetab/chcp/main/utils/URLUtility.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.nordnetab.chcp.main.utils;

import android.util.Log;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;

Expand All @@ -21,12 +24,14 @@ public class URLUtility {
public static URL stringToUrl(String urlString) {
URL url = null;
try {
url = new URL(URLDecoder.decode(urlString, "UTF-8"));
url = new URL(urlString);
final URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
url = uri.toURL();
} catch (Exception e) {
try {
url = new URL(urlString);
} catch (MalformedURLException e2) {
e2.printStackTrace();
Log.d("CHCP", "Failed to transfer url string \"" + urlString + "\" to actual url", e2);
}
}

Expand Down

0 comments on commit 87e0325

Please sign in to comment.