org.codehaus.plexus.util.IOUtil.toByteArray()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中org.codehaus.plexus.util.IOUtil.toByteArray()方法的一些代码示例,展示了IOUtil.toByteArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtil.toByteArray()方法的具体详情如下:
包路径:org.codehaus.plexus.util.IOUtil
类名称:IOUtil
方法名:toByteArray

IOUtil.toByteArray介绍

[英]Get the contents of an InputStream as a byte[].
[中]将InputStream的内容作为byte[]获取。

代码示例

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * Get the contents of a <code>Reader</code> as a <code>byte[]</code>.
 */
public static byte[] toByteArray( final Reader input )
  throws IOException
{
  return toByteArray( input, DEFAULT_BUFFER_SIZE );
}

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * Get the contents of a <code>String</code> as a <code>byte[]</code>.
 */
public static byte[] toByteArray( final String input )
  throws IOException
{
  return toByteArray( input, DEFAULT_BUFFER_SIZE );
}

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * Get the contents of an <code>InputStream</code> as a <code>byte[]</code>.
 */
public static byte[] toByteArray( final InputStream input )
  throws IOException
{
  return toByteArray( input, DEFAULT_BUFFER_SIZE );
}

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

/**
 * Get the contents of a <code>String</code> as a <code>byte[]</code>.
 */
public static byte[] toByteArray( final String input )
  throws IOException
{
  return toByteArray( input, DEFAULT_BUFFER_SIZE );
}

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

/**
 * Get the contents of a <code>Reader</code> as a <code>byte[]</code>.
 */
public static byte[] toByteArray( final Reader input )
  throws IOException
{
  return toByteArray( input, DEFAULT_BUFFER_SIZE );
}

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

/**
 * Get the contents of an <code>InputStream</code> as a <code>byte[]</code>.
 */
public static byte[] toByteArray( final InputStream input )
  throws IOException
{
  return toByteArray( input, DEFAULT_BUFFER_SIZE );
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-maven-checkstyle

@Override
  public void run() {
    InputStream urlis = null;
    try {
      urlis = url.openStream();
      byte[] arr = IOUtil.toByteArray(urlis);
      synchronized (AuxPropsImpl.this) {
        //#174401
        ByteArrayInputStream bais = new ByteArrayInputStream(arr);
        copyToCacheDir(bais);
        recheck = true;
      }
    } catch (IOException ex) {
      ex.printStackTrace();
    } finally {
      IOUtil.close(urlis);
    }
  }
});

代码示例来源:origin: chrisdchristo/capsule-maven-plugin

private void addMavenCapletClasses(final JarOutputStream jar) throws IOException {
  if (resolveApp || resolveCompileDep || resolveRuntimeDep || resolveProvidedDep || resolveSystemDep || resolveTestDep) {
    // get capsule maven classes
    final JarInputStream capsuleJarInputStream = new JarInputStream(new FileInputStream(resolveCapsuleMaven()));
    JarEntry entry;
    while ((entry = capsuleJarInputStream.getNextJarEntry()) != null) {
      if (entry.getName().contains("capsule") || entry.getName().equals(DEFAULT_CAPSULE_MAVEN_CLASS)) {
        addToJar(entry.getName(), new ByteArrayInputStream(IOUtil.toByteArray(capsuleJarInputStream)), jar);
      }
    }
    info("\t[Maven Caplet] Embedded Maven Caplet classes v" + capsuleMavenVersion + " (so capsule can resolve at launch)");
  }
}

代码示例来源:origin: chrisdchristo/capsule-maven-plugin

private void addCapsuleClass(final JarOutputStream jar) throws IOException {
  final JarInputStream capsuleJarInputStream = new JarInputStream(new FileInputStream(resolveCapsule()));
  JarEntry entry;
  while ((entry = capsuleJarInputStream.getNextJarEntry()) != null) // look for Capsule.class
    if (entry.getName().equals(DEFAULT_CAPSULE_CLASS))
      addToJar(DEFAULT_CAPSULE_CLASS, new ByteArrayInputStream(IOUtil.toByteArray(capsuleJarInputStream)), jar);
}

代码示例来源:origin: eclipse/tycho

@Override
public ArtifactDelta getDelta(InputStream baseline, InputStream reactor, MojoExecution mojo) throws IOException {
  byte[] baselineBytes = IOUtil.toByteArray(baseline);
  byte[] reactorBytes = IOUtil.toByteArray(reactor);
  String baselineDisassemble = null;
  String reactorDisassemble = null;
  boolean equal;
  try {
    baselineDisassemble = disassemble(baselineBytes);
    reactorDisassemble = disassemble(reactorBytes);
    equal = baselineDisassemble.equals(reactorDisassemble);
  } catch (RuntimeException e) {
    // asm could not disassemble one of the classes, fallback to byte-to-byte comparison
    equal = Arrays.equals(baselineBytes, reactorBytes);
  }
  return !equal ? new SimpleArtifactDelta("different", baselineDisassemble, reactorDisassemble) : null;
}

代码示例来源:origin: m2e-code-quality/m2e-code-quality

protected void copyIfChanged(InputStream input, Path output) throws IOException {
  InputStream source = input;
  if (Files.exists(output)) {
    byte[] fileContent = IOUtil.toByteArray(input);
    ByteArrayInputStream bufferedInput = new ByteArrayInputStream(fileContent);
    // compare content first
    try (InputStream outputContent = Files.newInputStream(output)) {
      if (IOUtil.contentEquals(bufferedInput, outputContent)) {
        return;
      }
    }
    // rewind input and use it
    bufferedInput.reset();
    source = bufferedInput;
  }
  Files.copy(source, output, StandardCopyOption.REPLACE_EXISTING);
}

代码示例来源:origin: org.sonatype.nexus.client/nexus-client-core

public String getResponseBody( final ClientResponse response )
{
  try
  {
    final byte[] body = IOUtil.toByteArray( response.getEntityInputStream() );
    response.setEntityInputStream( new ByteArrayInputStream( body ) );
    return IOUtil.toString( body, "UTF-8" );
  }
  catch ( IOException e )
  {
    throw new IllegalStateException( "Jersey unexpectedly refused to rewind buffered entity." );
  }
}

代码示例来源:origin: org.apache.maven.doxia/doxia-site-renderer

byte[] content = IOUtil.toByteArray( in );

代码示例来源:origin: com.github.veithen.maven.shared/aggregating-mojo

static synchronized AggregationHelper getAggregationHelper() throws RBeanFactoryException, IOException {
    if (aggregationHelper == null) {
      ClassLoader targetClassLoader = MavenSession.class.getClassLoader();
      synchronized (targetClassLoader) {
        try {
          targetClassLoader.loadClass(AggregationHelper.IMPL_CLASS);
        } catch (ClassNotFoundException ex) {
          ClassLoaderRBean targetClassLoaderRBean = new RBeanFactory(ClassLoaderRBean.class).createRBean(ClassLoaderRBean.class, targetClassLoader);
          ClassLoader sourceClassLoader = AggregationHelperFactory.class.getClassLoader();
          for (String className : classesToInject) {
            try (InputStream in = sourceClassLoader.getResourceAsStream(className.replace('.', '/') + ".class")) {
              byte[] data = IOUtil.toByteArray(in);
              targetClassLoaderRBean.defineClass(className, data, 0, data.length);
            }
          }
        }
      }
      aggregationHelper = new RBeanFactory(targetClassLoader, AggregationHelper.class).createRBean(AggregationHelper.class);
    }
    return aggregationHelper;
  }
}

相关文章