Here you can find the source of convertURLToFile(URL url)
public static File convertURLToFile(URL url)
//package com.java2s; /*/*ww w .ja v a 2 s. c o m*/ * Copyright 2011-2016 ZXC.com All right reserved. This software is the confidential and proprietary information of * ZXC.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into with ZXC.com. */ import java.io.File; import java.io.UnsupportedEncodingException; import java.net.URISyntaxException; import java.net.URL; import java.net.URLDecoder; public class Main { public static File convertURLToFile(URL url) { if (url == null) { return null; } try { return new File(url.toURI()); } catch (URISyntaxException e) { try { return new File(URLDecoder.decode(url.getPath(), "UTF-8")); } catch (UnsupportedEncodingException e1) { return new File(url.getPath()); } } } }