import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLEncoder;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileSystem;
* @author Changhyun Lee {@literal <changhyun1.lee@samsung.com>} (S-Core)
*/
public class FileUtil {
+ public static final String UTF_8 = "UTF-8"; //$NON-NLS-1$
+
private static final int BUFFER_SIZE = 8192;
/**
IFileSystem fileSystem = EFS.getLocalFileSystem();
fileSystem.getStore(source).copy(fileSystem.getStore(destination), options, monitor);
}
+
+ /**
+ * convert URL to URI safely
+ *
+ * @param url The source URL.
+ * @return The converted URI.
+ * @author Jihoon Song {@literal <jihoon80.song@samsung.com>} (S-Core)
+ * @throws UnsupportedEncodingException
+ */
+ public static URI convertURLtoURI(URL url) throws URISyntaxException, UnsupportedEncodingException {
+ if (url == null) {
+ return null;
+ }
+
+ return new URI(URLEncoder.encode(url.toString(), UTF_8));
+ }
}