org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(12.0k)|赞(0)|评价(0)|浏览(149)

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

Util.getInputStreamAsByteArray介绍

[英]Returns the given input stream's contents as a byte array. If a length is specified (i.e. if length != -1), only length bytes are returned. Otherwise all bytes in the stream are returned. Note this doesn't close the stream.
[中]以字节数组的形式返回给定输入流的内容。如果指定了长度(即如果长度!=-1),则只返回长度字节。否则,将返回流中的所有字节。注意,这不会关闭流。

代码示例

代码示例来源:origin: com.vaadin/vaadin-client-compiler-deps

/**
 * Returns the contents of the given file as a byte array.
 * @throws IOException if a problem occured reading the file.
 */
public static byte[] getFileByteContent(File file) throws IOException {
  InputStream stream = null;
  try {
    stream = new BufferedInputStream(new FileInputStream(file));
    return getInputStreamAsByteArray(stream, (int) file.length());
  } finally {
    if (stream != null) {
      try {
        stream.close();
      } catch (IOException e) {
        // ignore
      }
    }
  }
}
/**

代码示例来源:origin: org.eclipse.jdt.core.compiler/ecj

public static char[] getInputStreamAsCharArray(InputStream stream, int length, String encoding) throws IOException {
  Charset charset = null;
  try {
    charset = Charset.forName(encoding);
  } catch (IllegalCharsetNameException e) {
    System.err.println("Illegal charset name : " + encoding); //$NON-NLS-1$
    return null;
  } catch(UnsupportedCharsetException e) {
    System.err.println("Unsupported charset : " + encoding); //$NON-NLS-1$
    return null;
  }
  CharsetDecoder charsetDecoder = charset.newDecoder();
  charsetDecoder.onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE);
  byte[] contents = org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray(stream, length);
  ByteBuffer byteBuffer = ByteBuffer.allocate(contents.length);
  byteBuffer.put(contents);
  byteBuffer.flip();
  return charsetDecoder.decode(byteBuffer).array();
}

代码示例来源:origin: org.eclipse.jetty.orbit/org.eclipse.jdt.core

public static char[] getInputStreamAsCharArray(InputStream stream, int length, String encoding) throws IOException {
  Charset charset = null;
  try {
    charset = Charset.forName(encoding);
  } catch (IllegalCharsetNameException e) {
    System.err.println("Illegal charset name : " + encoding); //$NON-NLS-1$
    return null;
  } catch(UnsupportedCharsetException e) {
    System.err.println("Unsupported charset : " + encoding); //$NON-NLS-1$
    return null;
  }
  CharsetDecoder charsetDecoder = charset.newDecoder();
  charsetDecoder.onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE);
  byte[] contents = org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray(stream, length);
  ByteBuffer byteBuffer = ByteBuffer.allocate(contents.length);
  byteBuffer.put(contents);
  byteBuffer.flip();
  return charsetDecoder.decode(byteBuffer).array();
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.compiler.apt

public static char[] getInputStreamAsCharArray(InputStream stream, int length, String encoding) throws IOException {
  Charset charset = null;
  try {
    charset = Charset.forName(encoding);
  } catch (IllegalCharsetNameException e) {
    System.err.println("Illegal charset name : " + encoding); //$NON-NLS-1$
    return null;
  } catch(UnsupportedCharsetException e) {
    System.err.println("Unsupported charset : " + encoding); //$NON-NLS-1$
    return null;
  }
  CharsetDecoder charsetDecoder = charset.newDecoder();
  charsetDecoder.onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE);
  byte[] contents = org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray(stream, length);
  ByteBuffer byteBuffer = ByteBuffer.allocate(contents.length);
  byteBuffer.put(contents);
  byteBuffer.flip();
  return charsetDecoder.decode(byteBuffer).array();
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

public static char[] getInputStreamAsCharArray(InputStream stream, int length, String encoding) throws IOException {
  Charset charset = null;
  try {
    charset = Charset.forName(encoding);
  } catch (IllegalCharsetNameException e) {
    System.err.println("Illegal charset name : " + encoding); //$NON-NLS-1$
    return null;
  } catch(UnsupportedCharsetException e) {
    System.err.println("Unsupported charset : " + encoding); //$NON-NLS-1$
    return null;
  }
  CharsetDecoder charsetDecoder = charset.newDecoder();
  charsetDecoder.onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE);
  byte[] contents = org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray(stream, length);
  ByteBuffer byteBuffer = ByteBuffer.allocate(contents.length);
  byteBuffer.put(contents);
  byteBuffer.flip();
  return charsetDecoder.decode(byteBuffer).array();
}

代码示例来源:origin: org.eclipse.jdt.core.compiler/ecj

public static char[] getInputStreamAsCharArray(InputStream stream, int length, String encoding) throws IOException {
  Charset charset = null;
  try {
    charset = Charset.forName(encoding);
  } catch (IllegalCharsetNameException e) {
    System.err.println("Illegal charset name : " + encoding); //$NON-NLS-1$
    return null;
  } catch(UnsupportedCharsetException e) {
    System.err.println("Unsupported charset : " + encoding); //$NON-NLS-1$
    return null;
  }
  CharsetDecoder charsetDecoder = charset.newDecoder();
  charsetDecoder.onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE);
  byte[] contents = org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray(stream, length);
  ByteBuffer byteBuffer = ByteBuffer.allocate(contents.length);
  byteBuffer.put(contents);
  byteBuffer.flip();
  return charsetDecoder.decode(byteBuffer).array();
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

public static char[] getInputStreamAsCharArray(InputStream stream, int length, String encoding) throws IOException {
  Charset charset = null;
  try {
    charset = Charset.forName(encoding);
  } catch (IllegalCharsetNameException e) {
    System.err.println("Illegal charset name : " + encoding); //$NON-NLS-1$
    return null;
  } catch(UnsupportedCharsetException e) {
    System.err.println("Unsupported charset : " + encoding); //$NON-NLS-1$
    return null;
  }
  CharsetDecoder charsetDecoder = charset.newDecoder();
  charsetDecoder.onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE);
  byte[] contents = org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray(stream, length);
  ByteBuffer byteBuffer = ByteBuffer.allocate(contents.length);
  byteBuffer.put(contents);
  byteBuffer.flip();
  return charsetDecoder.decode(byteBuffer).array();
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

protected static byte[] readByteTable(String filename) throws java.io.IOException {

  //files are located at Parser.class directory

  InputStream stream = Parser.class.getResourceAsStream(filename);
  if (stream == null) {
    throw new java.io.IOException(Messages.bind(Messages.parser_missingFile, filename));
  }
  byte[] bytes = null;
  try {
    stream = new BufferedInputStream(stream);
    bytes = Util.getInputStreamAsByteArray(stream, -1);
  } finally {
    try {
      stream.close();
    } catch (IOException e) {
      // ignore
    }
  }
  return bytes;
}
protected static long[] readLongTable(String filename) throws java.io.IOException {

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

protected static byte[] readByteTable(String filename) throws java.io.IOException {

  //files are located at Parser.class directory

  InputStream stream = Parser.class.getResourceAsStream(filename);
  if (stream == null) {
    throw new java.io.IOException(Messages.bind(Messages.parser_missingFile, filename));
  }
  byte[] bytes = null;
  try {
    stream = new BufferedInputStream(stream);
    bytes = Util.getInputStreamAsByteArray(stream, -1);
  } finally {
    try {
      stream.close();
    } catch (IOException e) {
      // ignore
    }
  }
  return bytes;
}
protected static long[] readLongTable(String filename) throws java.io.IOException {

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

public static ClassFileReader read(InputStream stream, String fileName, boolean fullyInitialize) throws ClassFormatException, IOException {
  byte classFileBytes[] = Util.getInputStreamAsByteArray(stream, -1);
  ClassFileReader classFileReader = new ClassFileReader(classFileBytes, fileName.toCharArray());
  if (fullyInitialize) {
    classFileReader.initialize();
  }
  return classFileReader;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/ecj

public static ClassFileReader read(InputStream stream, String fileName, boolean fullyInitialize) throws ClassFormatException, IOException {
  byte classFileBytes[] = Util.getInputStreamAsByteArray(stream, -1);
  ClassFileReader classFileReader = new ClassFileReader(classFileBytes, fileName.toCharArray());
  if (fullyInitialize) {
    classFileReader.initialize();
  }
  return classFileReader;
}

代码示例来源:origin: com.vaadin/vaadin-client-compiler-deps

public static ClassFileReader read(InputStream stream, String fileName, boolean fullyInitialize) throws ClassFormatException, IOException {
  byte classFileBytes[] = Util.getInputStreamAsByteArray(stream, -1);
  ClassFileReader classFileReader = new ClassFileReader(classFileBytes, fileName.toCharArray());
  if (fullyInitialize) {
    classFileReader.initialize();
  }
  return classFileReader;
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

public static ClassFileReader read(InputStream stream, String fileName, boolean fullyInitialize) throws ClassFormatException, IOException {
  byte classFileBytes[] = Util.getInputStreamAsByteArray(stream, -1);
  ClassFileReader classFileReader = new ClassFileReader(classFileBytes, fileName.toCharArray());
  if (fullyInitialize) {
    classFileReader.initialize();
  }
  return classFileReader;
}

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

public static ClassFileReader read(InputStream stream, String fileName, boolean fullyInitialize) throws ClassFormatException, IOException {
  byte classFileBytes[] = Util.getInputStreamAsByteArray(stream, -1);
  ClassFileReader classFileReader = new ClassFileReader(classFileBytes, fileName.toCharArray());
  if (fullyInitialize) {
    classFileReader.initialize();
  }
  return classFileReader;
}

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

public static ClassFileReader read(InputStream stream, String fileName, boolean fullyInitialize) throws ClassFormatException, IOException {
  byte classFileBytes[] = Util.getInputStreamAsByteArray(stream, -1);
  ClassFileReader classFileReader = new ClassFileReader(classFileBytes, fileName.toCharArray());
  if (fullyInitialize) {
    classFileReader.initialize();
  }
  return classFileReader;
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

public static ClassFileReader read(InputStream stream, String fileName, boolean fullyInitialize) throws ClassFormatException, IOException {
  byte classFileBytes[] = Util.getInputStreamAsByteArray(stream, -1);
  ClassFileReader classFileReader = new ClassFileReader(classFileBytes, fileName.toCharArray());
  if (fullyInitialize) {
    classFileReader.initialize();
  }
  return classFileReader;
}

代码示例来源:origin: org.eclipse.jdt.core.compiler/ecj

public static ClassFileReader read(InputStream stream, String fileName, boolean fullyInitialize) throws ClassFormatException, IOException {
  byte classFileBytes[] = Util.getInputStreamAsByteArray(stream, -1);
  ClassFileReader classFileReader = new ClassFileReader(classFileBytes, fileName.toCharArray());
  if (fullyInitialize) {
    classFileReader.initialize();
  }
  return classFileReader;
}

代码示例来源:origin: org.eclipse.jetty.orbit/org.eclipse.jdt.core

public static ClassFileReader read(InputStream stream, String fileName, boolean fullyInitialize) throws ClassFormatException, IOException {
  byte classFileBytes[] = Util.getInputStreamAsByteArray(stream, -1);
  ClassFileReader classFileReader = new ClassFileReader(classFileBytes, fileName.toCharArray());
  if (fullyInitialize) {
    classFileReader.initialize();
  }
  return classFileReader;
}

代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core

public static ClassFileReader read(InputStream stream, String fileName, boolean fullyInitialize) throws ClassFormatException, IOException {
  byte classFileBytes[] = Util.getInputStreamAsByteArray(stream, -1);
  ClassFileReader classFileReader = new ClassFileReader(classFileBytes, fileName.toCharArray());
  if (fullyInitialize) {
    classFileReader.initialize();
  }
  return classFileReader;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

public static ClassFileReader read(InputStream stream, String fileName, boolean fullyInitialize) throws ClassFormatException, IOException {
  byte classFileBytes[] = Util.getInputStreamAsByteArray(stream, -1);
  ClassFileReader classFileReader = new ClassFileReader(classFileBytes, fileName.toCharArray());
  if (fullyInitialize) {
    classFileReader.initialize();
  }
  return classFileReader;
}

相关文章