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


Java IOUtil.toString方法代码示例

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


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

示例1: addJavaSource

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
private void addJavaSource( Set<String> resources, JarOutputStream jos, String name, InputStream is,
                            List<Relocator> relocators, boolean consistentDates )
    throws IOException
{
    JarEntry jarEntry = new ConsistentJarEntry( name, consistentDates );
    jos.putNextEntry( jarEntry );

    String sourceContent = IOUtil.toString( new InputStreamReader( is, "UTF-8" ) );

    for ( Relocator relocator : relocators )
    {
        sourceContent = relocator.applyToSourceContent( sourceContent );
    }

    final Writer writer = new OutputStreamWriter( jos, "UTF-8" );
    IOUtil.copy( sourceContent, writer );
    writer.flush();

    resources.add( name );
}
 
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:21,代码来源:DefaultShader.java

示例2: testPluginPomWorksAndOutputsHtmlReportAndXmlReport

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
public void testPluginPomWorksAndOutputsHtmlReportAndXmlReport() throws Exception {
  mojo = lookupMojoFromPom("xmlTestability.xml");
  assertNotNull(mojo);
  mojo.execute();

  File outputDir = (File) getVariableValueFromObject(mojo, "outputDirectory");
  String resultFile = (String) getVariableValueFromObject(mojo, "resultfile");
  File targetDir = (File) getVariableValueFromObject(mojo, "targetDirectory");

  File results = new File(outputDir, resultFile + ".html");
  assertTrue("HTML report should exist: " + results.getAbsolutePath(), results.exists());
  String content = IOUtil.toString(new FileReader(results));
  assertTrue("HTML report content: " + content, content.contains("TestabilityExplorerMojo"));

  results = new File(targetDir, resultFile + ".xml");
  assertTrue("XML report should exist: " + results.getAbsolutePath(), results.exists());
  content = IOUtil.toString(new FileReader(results));
  assertTrue("XML report content: " + content, content.contains("TestabilityExplorerMojo"));
}
 
开发者ID:mhevery,项目名称:testability-explorer,代码行数:20,代码来源:TestabilityMojoTest.java

示例3: addJavaSource

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
private void addJavaSource(Set<String> resources, JarOutputStream jos, String name, InputStream is,
    List<Relocator> relocators)
    throws IOException {
  jos.putNextEntry(new JarEntry(name));

  String sourceContent = IOUtil.toString(new InputStreamReader(is, "UTF-8"));

  for (Relocator relocator : relocators) {
    sourceContent = relocator.applyToSourceContent(sourceContent);
  }

  OutputStreamWriter writer = new OutputStreamWriter(jos, "UTF-8");
  IOUtil.copy(sourceContent, writer);
  writer.flush();
  resources.add(name);
}
 
开发者ID:immutables,项目名称:maven-shade-plugin,代码行数:17,代码来源:DefaultShader.java

示例4: readServiceEntry

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
private void readServiceEntry(String name, InputStream inputStream) throws IOException {
  if (!isIncluded(name)) {
    return;
  }
  String typeName = toClassFilePath(name.replace(SERVICES_ENTRY_PREFIX, ""));

  if (typeName.isEmpty()) {
    return;
  }

  boolean forcedInclusion = isSpecificallyIncluded(name);
  if (forcedInclusion) {
    included.add(typeName);
  }

  String content = IOUtil.toString(inputStream, Charsets.UTF_8.name());
  for (String providerType : SERVICES_SPLITTER.split(content)) {
    String providerName = toClassFilePath(providerType);
    services.put(typeName, providerName);

    if (forcedInclusion) {
      included.add(providerName);
    }
  }
}
 
开发者ID:immutables,项目名称:maven-shade-plugin,代码行数:26,代码来源:ClassDependencies.java

示例5: generate

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
@Override protected void generate() throws Exception {
  File pd = new File(outputDirectory, packageName.replaceAll("\\.", "/"));
  if (getLog().isDebugEnabled()) {
    getLog().info("Creating directory " + pd);
  }
  pd.mkdirs();

  InputStream in = null;
  try {
    in = ResourceMojo.class.getResourceAsStream(
            "/net/hydromatic/resource/Resources.java");
    String template = IOUtil.toString(in, "UTF-8");
    template = template.replace("package net.hydromatic.resource;",
        "package " + packageName + ";");
    saveResult(new File(pd, "Resources.java"), template);
  } finally {
    if (in != null) {
      in.close();
    }
  }
}
 
开发者ID:julianhyde,项目名称:hydromatic-resource,代码行数:22,代码来源:ResourceMojo.java

示例6: findCluster

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
private String findCluster( JarFile jf )
    throws MojoFailureException, IOException
{
    ZipEntry entry = jf.getEntry( "Info/info.xml" );
    InputStream ins = jf.getInputStream( entry );
    String str = IOUtil.toString( ins, "UTF8" );
    Matcher m = patt.matcher( str );
    if ( !m.matches() )
    {
        getLog().info( "Cannot find cluster for " + jf.getName() + " Falling back to default value - '"
                           + defaultCluster + "'." );
        return defaultCluster;
    }
    else
    {
        return m.group( 1 );
    }
}
 
开发者ID:bitstrings,项目名称:nbm-maven,代码行数:19,代码来源:CreateClusterAppMojo.java

示例7: loadAllFunctionTemplates

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
protected List<FunctionTemplate> loadAllFunctionTemplates() throws Exception {
    info("");
    info(LOAD_TEMPLATES);

    try (final InputStream is = AddMojo.class.getResourceAsStream("/templates.json")) {
        final String templatesJsonStr = IOUtil.toString(is);
        final List<FunctionTemplate> templates = parseTemplateJson(templatesJsonStr);
        info(LOAD_TEMPLATES_DONE);
        return templates;
    } catch (Exception e) {
        error(LOAD_TEMPLATES_FAIL);
        throw e;
    }
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:15,代码来源:AddMojo.java

示例8: getLatestVersion

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
private String getLatestVersion() {
	String url = "http://search.maven.org/solrsearch/select";
	String param = "g:\"_groupid_\" AND a:\"_artifactid_\"";
	param = param.replace("_groupid_", groupId).replace("_artifactid_", artifactId);

	try {
		List<NameValuePair> paramList = new ArrayList<>();
		NameValuePair nvp1 = new BasicNameValuePair("q", param);
		paramList.add(nvp1);
		NameValuePair nvp2 = new BasicNameValuePair("wt", "json");
		paramList.add(nvp2);

		HttpClient client = HttpClientBuilder.create().build();
		HttpGet request = new HttpGet(url);
		URI uri = new URIBuilder(request.getURI()).addParameters(paramList).build();
		request.setURI(uri);

		HttpResponse response = client.execute(request);
		if (response.getStatusLine().getStatusCode() != 200) {
			return "1.0.0";
		}

		HttpEntity entity = response.getEntity();
		InputStream is = entity.getContent();
		String res = IOUtil.toString(is);

		Gson gson = new GsonBuilder().create();
		MavenResponse mavenResponse = gson.fromJson(res, MavenResponse.class);
		if (mavenResponse.response.docs == null || mavenResponse.response.docs.isEmpty()) {
			return "1.0.0";
		}

		return mavenResponse.response.docs.get(0).latestVersion;
	} catch (Exception e) {
		return "1.0.0";
	}
}
 
开发者ID:dice-project,项目名称:DICE-Platform,代码行数:38,代码来源:QualityTestingNewProjectWizard.java

示例9: loadTextResource

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
private String loadTextResource(URL resource) throws IOException {
    InputStream is = resource.openStream();
    try {
        return IOUtil.toString(is, "UTF-8");
    } finally {
        IOUtil.close(is);
    }
}
 
开发者ID:jboss-fuse,项目名称:hawt-app,代码行数:9,代码来源:BuildMojo.java

示例10: getReference

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
private static String getReference(String artifactUrlReference) throws IOException {
    URL referenceUrl = new URL(artifactUrlReference);
    InputStream referenceUrlStream = referenceUrl.openStream();
    String reference = IOUtil.toString(referenceUrlStream);
    if(reference==null || reference.isEmpty() || reference.contains("\n")){
        throw new IllegalArgumentException("artifactUrlReference resource should be non empty");
    }
    return reference;
}
 
开发者ID:igor-suhorukov,项目名称:mvn-classloader,代码行数:10,代码来源:UrlBootstrapLoader.java

示例11: readXmlFile

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
/**
 * Reads a file into a String.
 *
 * @param outFile The file to read.
 * @return String The content of the file.
 * @throws java.io.IOException when things go wrong.
 */
public static StringBuilder readXmlFile( File outFile )
    throws IOException
{
    try( Reader reader = ReaderFactory.newXmlReader( outFile ) )
    {
        return new StringBuilder( IOUtil.toString( reader ) );
    }
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:16,代码来源:PomHelper.java

示例12: createCassandraYaml

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
/**
 * Generates the {@code cassandra.yaml} file.
 *
 * @param cassandraYaml the {@code cassandra.yaml} file.
 * @param data          The data directory.
 * @param commitlog     The commitlog directory.
 * @param savedCaches   The saved caches directory.
 * @param listenAddress The address to listen on for storage and other cassandra servers.
 * @param rpcAddress    The address to listen on for clients.
 * @param seeds         The seeds.
 * @throws IOException If something went wrong.
 */
private void createCassandraYaml( File cassandraYaml, File data, File commitlog, File savedCaches,
                                  String listenAddress, String rpcAddress, BigInteger initialToken, String[] seeds )
    throws IOException
{
    String defaults = IOUtil.toString( getClass().getResourceAsStream( "/cassandra.yaml" ) );
    StringBuilder config = new StringBuilder();
    config.append( "data_file_directories:\n" ).append( "    - " ).append( data.getAbsolutePath() ).append( "\n" );
    config.append( "commitlog_directory: " ).append( commitlog ).append( "\n" );
    config.append( "saved_caches_directory: " ).append( savedCaches ).append( "\n" );
    config.append( "initial_token: " ).append(
        initialToken == null || "null".equals( initialToken ) ? "" : initialToken.toString() ).append( "\n" );
    config.append( "listen_address: " ).append( listenAddress ).append( "\n" );
    config.append( "storage_port: " ).append( storagePort ).append( "\n" );
    config.append( "rpc_address: " ).append( rpcAddress ).append( "\n" );
    config.append( "rpc_port: " ).append( rpcPort ).append( "\n" );
    config.append( "native_transport_port: " ).append( nativeTransportPort ).append( "\n" );
    config.append( "start_native_transport: " ).append( startNativeTransport ).append( "\n" );
    if ( seeds != null )
    {
        config.append( "seed_provider: " ).append( "\n" );
        config.append( "    - class_name: org.apache.cassandra.locator.SimpleSeedProvider" ).append( "\n" );
        config.append( "      parameters:" ).append( "\n" );
        String sep = "          - seeds: \"";
        for ( int i = 0; i < seeds.length; i++ )
        {
            config.append( sep ).append( seeds[i] );
            sep = ", ";
        }
        if ( sep.length() == 2 )
        {
            config.append( "\"" ).append( "\n" );
        }
    }
    FileUtils.fileWrite( cassandraYaml.getAbsolutePath(),
                         Utils.merge( Utils.merge( defaults, yaml ), config.toString() ) );
}
 
开发者ID:mojohaus,项目名称:cassandra-maven-plugin,代码行数:49,代码来源:AbstractCassandraMojo.java

示例13: readXmlFile

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
/**
 * Reads a file into a String.
 *
 * @param outFile The file to read.
 * @return String The content of the file.
 * @throws java.io.IOException when things go wrong.
 */
public static StringBuilder readXmlFile( File outFile )
    throws IOException
{
    Reader reader = ReaderFactory.newXmlReader( outFile );

    try
    {
        return new StringBuilder( IOUtil.toString( reader ) );
    }
    finally
    {
        IOUtil.close( reader );
    }
}
 
开发者ID:petr-ujezdsky,项目名称:versions-maven-plugin-svn-clone,代码行数:22,代码来源:PomHelper.java

示例14: load

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
@Override
public Source load(final String sourceFile) throws IOException {
    InputStream stream = locate(sourceFile);
    if (stream != null) {
        try (Md5DigestInputStream ds = new Md5DigestInputStream(stream);
                InputStreamReader reader = new InputStreamReader(ds, getSourceEncoding())) {
            String source = IOUtil.toString(reader);
            return new Source(getFileName(sourceFile), source, ds.getDigestHex());
        } catch (NoSuchAlgorithmException ex) {
            throw new IOException("MD5 algorithm not available", ex);
        }
    } else {
        return null;
    }
}
 
开发者ID:trautonen,项目名称:coveralls-maven-plugin,代码行数:16,代码来源:AbstractSourceLoader.java

示例15: readFileContent

import org.codehaus.plexus.util.IOUtil; //导入方法依赖的package包/类
public static String readFileContent(final File file) throws IOException {
    InputStreamReader reader = new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8"));
    try {
        return IOUtil.toString(reader);
    } finally {
        IOUtil.close(reader);
    }
}
 
开发者ID:trautonen,项目名称:coveralls-maven-plugin,代码行数:9,代码来源:TestIoUtil.java


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