当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.copyURLToFile方法代码示例

本文整理汇总了Java中org.apache.commons.io.FileUtils.copyURLToFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.copyURLToFile方法的具体用法?Java FileUtils.copyURLToFile怎么用?Java FileUtils.copyURLToFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.io.FileUtils的用法示例。


在下文中一共展示了FileUtils.copyURLToFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testExecute

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Test
public void testExecute() throws IOException, InterruptedException {

	File baseFile = folder.newFile("test.ps1");

	FileUtils.copyURLToFile(getClass().getResource("/testFiles/test.ps1"), baseFile);

	DefaultFileSystem fs = new DefaultFileSystem(folder.getRoot());
	DefaultInputFile ti = new DefaultInputFile("test", "test.ps1");
	ti.initMetadata(new String(Files.readAllBytes(baseFile.toPath())));
	ti.setLanguage(PowershellLanguage.KEY);
	fs.add(ti);

	SensorContextTester ctxTester = SensorContextTester.create(folder.getRoot());
	ctxTester.setFileSystem(fs);
	TokenizerSensor s = new TokenizerSensor(new Settings(), temp);
	s.execute(ctxTester);
	Assert.assertEquals(16, ctxTester.cpdTokens("test:test.ps1").size());
	Assert.assertEquals(1, ctxTester.highlightingTypeAt("test:test.ps1", 1, 5).size());

}
 
开发者ID:gretard,项目名称:sonar-ps-plugin,代码行数:22,代码来源:TokenizerSensorTest.java

示例2: resolveAssets

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void resolveAssets(Version versionData) throws Throwable {
	Version.AssetIndex assetIndex = versionData.assetIndex;
	File assetsInfo = new File(ASSETS, "indexes" + File.separator + assetIndex.id + ".json");
	FileUtils.copyURLToFile(new URL(assetIndex.url), assetsInfo);
	AssetIndex index = new Gson().fromJson(new FileReader(assetsInfo), AssetIndex.class);
	Map<String, AssetObject> parent = index.getFileMap();
	i = 0;
	count = parent.entrySet().size();
	NotifyUtil.setProgress(-1);
	NotifyUtil.setText("Resolving %s Minecraft Assets", count);
	parent.entrySet().parallelStream().forEach(entry -> {
		AssetObject object = entry.getValue();
		String sha1 = object.getHash();
		File file = new File(ASSETS, "objects" + File.separator + sha1.substring(0, 2) + File.separator + sha1);
		NotifyUtil.setProgressAscend(i++, count);
		if (!file.exists() || !MiscUtil.checksumEquals(file, sha1)) {
			OneClientLogging.info("Downloading asset " + entry.getKey() + " from " + Constants.RESOURCES_BASE + sha1.substring(0, 2) + "/" + sha1 + " to " + file);
			try {
				FileUtils.copyURLToFile(new URL(Constants.RESOURCES_BASE + sha1.substring(0, 2) + "/" + sha1), file);
				FileUtils.copyURLToFile(new URL(Constants.RESOURCES_BASE + sha1.substring(0, 2) + "/" + sha1), file);
			} catch (IOException e) {
				OneClientLogging.error(e);
			}
		}
	});
}
 
开发者ID:HearthProject,项目名称:OneClient,代码行数:27,代码来源:MinecraftUtil.java

示例3: downloadINI

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public void downloadINI(){
  	File ini=new File(path+"\\bin64\\arcdps.ini");
  	if (ini.exists()) ini.delete(); //Delete existing ini file to prevent an exception
  	log.log( Level.INFO,"Downloading configuration file");
  	try {
  		//Download default configuration from the website
	FileUtils.copyURLToFile(new URL("http://www.deltaconnected.com/arcdps/x64/arcdps.ini"),ini, 10000, 10000);
	log.log( Level.INFO,"archdps.ini installed successfully");
	//Exceptions if something goes wrong (Connection/IO)
} catch (IOException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
	cf.status.setText("  Cannot connect to the update server");
          cf.status.setForeground(Color.RED);
          log.log( Level.SEVERE,"IOException when downloading ini");
}

  }
 
开发者ID:LithiumSR,项目名称:gw2_launcher,代码行数:19,代码来源:FastUpdater.java

示例4: downloadINI

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static synchronized void downloadINI(CoreFrame cf, String path){
Operations.LogSetup(log,true);
  	File ini=new File(path+"\\bin64\\arcdps.ini");
  	if (ini.exists()) ini.delete();     	//Delete existing ini file to prevent an exception
  	log.log( Level.INFO,"Downloading configuration file");
  	try {
  		//Download default configuration from the website
	FileUtils.copyURLToFile(new URL("http://www.deltaconnected.com/arcdps/x64/arcdps.ini"),ini, 10000, 10000);
	log.log( Level.INFO,"archdps.ini installed successfully");
//Exceptions if something goes wrong (Connection/IO)
  	} catch (IOException e) {
	
	e.printStackTrace();
	cf.status.setText("- Cannot connect to the update server");
          cf.status.setForeground(Color.RED);
          log.log( Level.SEVERE,"IOException when downloading ini");
}
  	Operations.closeLogHandlers(log);
  }
 
开发者ID:LithiumSR,项目名称:gw2_launcher,代码行数:20,代码来源:Operations.java

示例5: run

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
public void run() {
    if (artifact.endsWith(".jar")) {
        artifact = artifact.replaceAll("jar", "wpk");
    } else
        artifact += ".wpk";
    File pluginFile = new File("plugins", artifact);
    try {
        FileUtils.copyURLToFile(url, pluginFile);
        ((WurstSDK) SDK.getClient()).getPluginManager().installPlugin(pluginFile, token);
    } catch (IOException e) {
        message = "Failed to download!: " + e.getMessage();
    }
    prevScreen.updateScreen();
    mc.displayGuiScreen(prevScreen);
}
 
开发者ID:WurstSDK-Team,项目名称:WurstSDK,代码行数:17,代码来源:GuiInstallScreen.java

示例6: downloadForgeJar

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static JarFile downloadForgeJar(File versionsDir, String mcVer, String forgeVer) throws IOException {
	ForgeVersions.ForgeVersion version = getForgeVersion(forgeVer);
	String jarName = getForgeJar(mcVer, forgeVer, null);
	File forgeJar = new File(Constants.TEMPDIR, jarName);
	File forgeSHA1 = new File(Constants.TEMPDIR, jarName + ".sha1");
	if(forgeJar.exists() && forgeSHA1.exists()){
		if(MiscUtil.checksumEquals(forgeJar, FileUtils.readFileToString(forgeSHA1, StandardCharsets.UTF_8))){
			return new JarFile(forgeJar);
		}
	}
	OneClientLogging.logger.info("Downloading forge jar to " + versionsDir.getAbsolutePath());
	if (version.branch != null && !version.branch.isEmpty()) {
		jarName = getForgeJar(mcVer, forgeVer, version.branch);
	}
	URL forgeSHA1URL = new URL("http://files.minecraftforge.net/maven/net/minecraftforge/forge/" + jarName + ".sha1");
	URL forgeJarURL = new URL("http://files.minecraftforge.net/maven/net/minecraftforge/forge/" + jarName);
	FileUtils.copyURLToFile(forgeSHA1URL, forgeSHA1);
	FileUtils.copyURLToFile(forgeJarURL, forgeJar);
	return new JarFile(forgeJar);
}
 
开发者ID:HearthProject,项目名称:OneClient,代码行数:21,代码来源:ForgeUtils.java

示例7: downloadUpdatePack

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * 下载更新文件
 * @return
 */
private boolean downloadUpdatePack(){
    try {
        URL url = new URL(downloadUrl);

        File f = new File(updateDownloadFilePath);
        log.info("{}downloading update file from {} ...",log4UpdateStart,downloadUrl);
        FileUtils.copyURLToFile(url, f);
        log.info("{}update file download completed!",log4UpdateStart);
        File zipDownloadFile = new File(updateFilesTempDir);
        if(zipDownloadFile.exists()){
            FileUtils.deleteDirectory(zipDownloadFile);
        }
        log.info("{}unpack update file to {}",log4UpdateStart,updateFilesTempDir);
        ZipUtil.unzip(updateDownloadFilePath, updateFilesTempDir);

        if(f.delete()){
            log.info("{}delete temp file {}",log4UpdateStart,updateDownloadFilePath);
        }
    } catch (Exception e) {
        log.info("{}download update file <FAILED>",log4UpdateStart,e);
        return false;
    }
    return true;
}
 
开发者ID:DevopsJK,项目名称:SuitAgent,代码行数:29,代码来源:Update.java

示例8: downloadFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * Download file from url.
 * 
 * @param url The url you want to download from.
 * @param target The target-file.
 * @return boolean
 */
public static boolean downloadFile( String url, File target )
{
    try
    {

        //Run download.
        FileUtils.copyURLToFile( new URL( url ), target );
                
        //Success.
        return true;
        
    }
    catch ( Exception ex )
    {
        
        //Post fail message.
        Console.debug( "Failed to download \"" + url + "\" to " + target.getPath() );

        
        //Failed.
        return false;
        
    }
}
 
开发者ID:ModdyLP,项目名称:MoMuOSB,代码行数:32,代码来源:WebClient.java

示例9: createDefaultConfiguration

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public void createDefaultConfiguration()
{
    try
    {
        File destinationFile = new File(MiscUtils.getJarFolder(), "config.json");
        FileUtils.copyURLToFile(Configuration.class.getResource("/config.json"), destinationFile);
    } catch (IOException e)
    {
        e.printStackTrace();
    }

    this.instance.log(Level.INFO, "Default configuration file created.");
    System.exit(3);
}
 
开发者ID:SamaGames,项目名称:Hydroangeas,代码行数:15,代码来源:Configuration.java

示例10: installMinecraft

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void installMinecraft(Instance instance) throws Throwable {
	instance.setInstalling(true);
	NotifyUtil.setText("Installing minecraft for " + instance.getName());
	OneClientTracking.sendRequest("minecraft/install/" + instance.getGameVersion());

	Version versionData = getVersion(instance.getGameVersion());

	if (versionData == null) {
		OneClientLogging.error("Unknown Game Version! Please Notify the Devs!");
		return;
	}

	File mcJar = new File(VERSIONS, instance.getGameVersion() + ".jar");

	OneClientLogging.logger.info("Downloading Minecraft jar");
	if (!MiscUtil.checksumEquals(mcJar, versionData.downloads.get("client").sha1)) {
		FileUtils.copyURLToFile(new URL(versionData.downloads.get("client").url), mcJar);
	}

	installLibraries(versionData);

	File natives = new File(VERSIONS, "natives-" + instance.gameVersion);
	extractNatives(natives, versionData);
	resolveAssets(versionData);

	if (!instance.getForgeVersion().isEmpty())
		ForgeUtils.resolveForgeLibrarys(instance.getGameVersion(), instance.getForgeVersion());

	OneClientLogging.logger.info("Done minecraft files are all downloaded");
	instance.setInstalling(false);
	NotifyUtil.clear();
}
 
开发者ID:HearthProject,项目名称:OneClient,代码行数:33,代码来源:MinecraftUtil.java

示例11: startPythonProcesses

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void startPythonProcesses()
{
    if (python2Process != null)
    {
        python2Process.destroy();
    }
    if (python3Process != null)
    {
        python3Process.destroy();
    }

    // copy dump_python.py to temp dir
    try
    {
        URL url = Thread.currentThread().getContextClassLoader().getResource(dumpPythonResource);
        FileUtils.copyURLToFile(url, new File(jsonizer));
    } catch (Exception e)
    {
        $.die("Failed to copy resource file:" + dumpPythonResource);
    }

    python2Process = startInterpreter(PYTHON2_EXE);
    if (python2Process != null)
    {
        $.msg("started: " + PYTHON2_EXE);
    }

    python3Process = startInterpreter(PYTHON3_EXE);
    if (python3Process != null)
    {
        $.msg("started: " + PYTHON3_EXE);
    }

    if (python2Process == null && python3Process == null)
    {
        $.die("You don't seem to have either of Python or Python3 on PATH");
    }
}
 
开发者ID:lebronzj,项目名称:pysonar2,代码行数:39,代码来源:Parser.java

示例12: Config

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public Config() throws Exception {
    configFile = new File("config.json");
    if(!configFile.exists()) {
        URL configResource = getClass().getClassLoader().getResource("config.json");
        FileUtils.copyURLToFile(configResource, configFile);
    }

    FileReader reader = new FileReader(configFile);
    json = new JSONObject(IOUtils.toString(reader));
    reader.close();
}
 
开发者ID:kazigk,项目名称:sagiri,代码行数:12,代码来源:Config.java

示例13: aclImdbDownloader

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void aclImdbDownloader(String DATA_URL, String DATA_PATH) {
    try {
        //Create directory if required
        File directory = new File(DATA_PATH);
        if (!directory.exists()) directory.mkdir();
        //Download file:
        String archivePath = DATA_PATH + "aclImdb_v1.tar.gz";
        File archiveFile = new File(archivePath);
        String extractedPath = DATA_PATH + "aclImdb";
        File extractedFile = new File(extractedPath);

        if (!archiveFile.exists()) {
            System.out.println("Starting data download (80MB)...");
            FileUtils.copyURLToFile(new URL(DATA_URL), archiveFile);
            System.out.println("Data (.tar.gz file) downloaded to " + archiveFile.getAbsolutePath());
            //Extract tar.gz file to output directory
            extractTarGz(archivePath, DATA_PATH);
        } else {
            //Assume if archive (.tar.gz) exists, then data has already been extracted
            System.out.println("Data (.tar.gz file) already exists at " + archiveFile.getAbsolutePath());
            if (!extractedFile.exists()) {
                //Extract tar.gz file to output directory
                extractTarGz(archivePath, DATA_PATH);
            } else {
                System.out.println("Data (extracted) already exists at " + extractedFile.getAbsolutePath());
            }
        }
    } catch(IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:IsaacChanghau,项目名称:Word2VecfJava,代码行数:32,代码来源:CNNSentenceClassification.java

示例14: setUpGeneratorTest

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Before
public void setUpGeneratorTest() throws Exception {
  URL url = getClass().getResource(ARCHIVE_FILE_NAME);
  File testFolder = this.temporaryFolder.newFolder(getClass().getSimpleName());
  this.expectedStatArchiveFile = new File(testFolder, ARCHIVE_FILE_NAME);
  FileUtils.copyURLToFile(url, this.expectedStatArchiveFile);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:8,代码来源:StatArchiveWithConsecutiveResourceInstGeneratorTest.java

示例15: resolveEntity

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Deprecated
public InputSource resolveEntity(String publicId, String systemId) throws IOException {
  if (!isHttpUrlOK(systemId)) {
    URL dtdURL = getClass().getResource(CacheXml.LATEST_DTD_LOCATION);
    File dtd = new File(DistributionConfig.GEMFIRE_PREFIX + "dtd");
    FileUtils.copyURLToFile(dtdURL, dtd);
    InputSource inputSource = new InputSource(FileUtils.openInputStream(dtd));
    FileUtils.deleteQuietly(dtd);
    return inputSource;
  } else {
    return null;
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:14,代码来源:DtdResolver.java


注:本文中的org.apache.commons.io.FileUtils.copyURLToFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。