Source:
<code>static boolean downloadFromVFS2(String path, Path targetFilePath, int threads) { <START> class CustomHttp4sFileProvider extends Http4sFileProvider { <END> public HttpClientContext createHttpClientContext(final Http4FileSystemConfigBuilder builder, final GenericFileName rootName, final FileSystemOptions fileSystemOptions, final UserAuthenticationData authData) throws FileSystemException { HttpClientContext def = super.createHttpClientContext(builder, rootName, fileSystemOptions, authData); if (rootName.getHostName().equals("github.com")) { def.setRequestConfig(RequestConfig.copy(def.getRequestConfig()).setCookieSpec(CookieSpecs.STANDARD).build()); } return def; } } try { DefaultFileSystemManager fsManager = (DefaultFileSystemManager)VFS.getManager(); String newPath = path; if (path.startsWith("http")) { if (!fsManager.hasProvider("http4")) { fsManager.addProvider("http4", new Http4FileProvider()); } if (!fsManager.hasProvider("http4s")) { CustomHttp4sFileProvider http4sFP = new CustomHttp4sFileProvider(); fsManager.addProvider("http4s", http4sFP); } if (path.startsWith("http:")) { newPath = newPath.replaceFirst("http:", "http4:"); } else if (path.startsWith("https:")) { newPath = newPath.replaceFirst("https:", "http4s:"); } } FileSystemOptions opts = new FileSystemOptions(); FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, true); try (FileObject src = fsManager.resolveFile(newPath, opts); FileObject dest = fsManager.resolveFile(targetFilePath.toFile().getAbsolutePath())) { copyFromInputStreamToOutputStream(src, dest, threads); } return true; } catch (IOException e) { LOG.error(e.getMessage()); return false; } }</code><technical_language>This static private class.... 1. private this class, practice more accessible need be. 2. static is a practice for classes, actual need for class access enclosing class</technical_language>

Target:
static boolean downloadFromVFS2(String path, Path targetFilePath, int threads) { class CustomHttp4sFileProvider extends Http4sFileProvider { public HttpClientContext createHttpClientContext(final Http4FileSystemConfigBuilder builder, final GenericFileName rootName, final FileSystemOptions fileSystemOptions, final UserAuthenticationData authData) throws FileSystemException { HttpClientContext def = super.createHttpClientContext(builder, rootName, fileSystemOptions, authData); if (rootName.getHostName().equals("github.com")) { def.setRequestConfig(RequestConfig.copy(def.getRequestConfig()).setCookieSpec(CookieSpecs.STANDARD).build()); } return def; } } try { DefaultFileSystemManager fsManager = (DefaultFileSystemManager)VFS.getManager(); String newPath = path; if (path.startsWith("http")) { if (!fsManager.hasProvider("http4")) { fsManager.addProvider("http4", new Http4FileProvider()); } if (!fsManager.hasProvider("http4s")) { fsManager.addProvider("http4s", new CustomHttp4sFileProvider()); } if (path.startsWith("http:")) { newPath = newPath.replaceFirst("http:", "http4:"); } else if (path.startsWith("https:")) { newPath = newPath.replaceFirst("https:", "http4s:"); } } FileSystemOptions opts = new FileSystemOptions(); FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, true); try (FileObject src = fsManager.resolveFile(newPath, opts); FileObject dest = fsManager.resolveFile(targetFilePath.toFile().getAbsolutePath())) { copyFromInputStreamToOutputStream(src, dest, threads); } return true; } catch (IOException e) { LOG.error(e.getMessage()); return false; } }