This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
FileObject retVal = null;
File file;
try {
file = FileUtil.normalizeFile(new File(url.toURI()));
file = FileUtil.normalizeFile(uri2File(url.toURI()));
} catch (URISyntaxException e) {
LOG.log(Level.INFO, "URL=" + url, e); // NOI18N
return null;
retVal = FileBasedFileSystem.getFileObject(file, FileObjectFactory.Caller.ToFileObject);
return new FileObject[]{retVal};
}
static File uri2File(URI uri) { // #207060: UNC; candidate for API (#46813)
if (uri.getHost() == null) {
return new File(uri);
} else {
return new File("\\\\" + uri.getHost() + uri.getPath().replace('/', '\\'));
private static URL fileToURL(final File file, final FileObject fo) throws MalformedURLException {
URL retVal = toURI(file, fo.isFolder()).toURL();
import org.openide.filesystems.URLMapper;
import org.openide.filesystems.FileUtil;
import java.net.URL;
import org.openide.util.Utilities;
/**
* @author Radek Matous
assertEquals("192.168.0.201", uri.getHost());
assertEquals("/data/services/web/com_resource/", uri.getPath());
public void testReverseUNCPath() throws Exception {
if (!Utilities.isWindows()) {
return;
assertEquals("C:\\some\\random path", FileBasedURLMapper.uri2File(new URI("file:/C:/some/random%20path/")).getAbsolutePath());
assertEquals("C:\\some\\random path", FileBasedURLMapper.uri2File(new URI("file:///C:/some/random%20path/")).getAbsolutePath());
assertEquals("\\\\server\\share\\some\\random path", FileBasedURLMapper.uri2File(new URI("file://server/share/some/random%20path/")).getAbsolutePath());
AGAIN: for (;;) try {
final URI uri = new URI(filePath);
if (uri.getScheme().equals("file")) {
jar = new File(uri).getPath();
jar = uri2File(uri).getPath();
jar = null;
return new NbJarURLConnection (u, _src, _name, loader);
private static File uri2File(URI uri) { // #207060: UNC; candidate for API (#46813)
@Override
protected void parseURL(URL u, String spec, int start, int limit) {
if (spec.startsWith("/")) {