java.io.BufferedInputStream.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(155)

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

BufferedInputStream.<init>介绍

[英]Creates a BufferedInputStream and saves its argument, the input stream in, for later use. An internal buffer array is created and stored in buf.
[中]创建BufferedInputStream并保存其参数,即输入流in,以供以后使用。内部缓冲区数组创建并存储在buf中。

代码示例

代码示例来源:origin: log4j/log4j

/**
 * Gets an input stream for the corresponding file.
 *
 * @param file The file to create the input stream from.
 * @return InputStream
 */
protected InputStream getInputStream(File file) throws IOException,
  FileNotFoundException {
 BufferedInputStream reader =
   new BufferedInputStream(new FileInputStream(file));
 return reader;
}

代码示例来源:origin: stanfordnlp/CoreNLP

public ByteStreamGobbler(String name, InputStream is, OutputStream out) {
 super(name);
 this.inStream = new BufferedInputStream(is);
 this.outStream = new BufferedOutputStream(out);
}

代码示例来源:origin: Tencent/tinker

public static void bsdiff(File oldFile, File newFile, File diffFile) throws IOException {
  InputStream oldInputStream = new BufferedInputStream(new FileInputStream(oldFile));
  InputStream newInputStream = new BufferedInputStream(new FileInputStream(newFile));
  OutputStream diffOutputStream = new FileOutputStream(diffFile);
  try {
    byte[] diffBytes = bsdiff(oldInputStream, (int) oldFile.length(), newInputStream, (int) newFile.length());
    diffOutputStream.write(diffBytes);
  } finally {
    diffOutputStream.close();
  }
}

代码示例来源:origin: apache/zookeeper

public void chop() {
  File targetFile = new File(txnLogFile.getParentFile(), txnLogFile.getName() + ".chopped" + zxid);
  try (
      InputStream is = new BufferedInputStream(new FileInputStream(txnLogFile));
      OutputStream os = new BufferedOutputStream(new FileOutputStream(targetFile))
  ) {
    if (!LogChopper.chop(is, os, zxid)) {
      throw new TxnLogToolkitException(ExitCode.INVALID_INVOCATION.getValue(), "Failed to chop %s", txnLogFile.getName());
    }
  } catch (Exception e) {
    System.out.println("Got exception: " + e.getMessage());
  }
}

代码示例来源:origin: spotbugs/spotbugs

@Override
public InputStream openStream(String resourceName) throws IOException {
  File file = new File(dirName, resourceName);
  if (!file.exists()) {
    return null;
  }
  return new BufferedInputStream(new FileInputStream(file));
}

代码示例来源:origin: libgdx/libgdx

public SetupPreferences () {		
  if (!file.exists()) return;
  InputStream in = null;
  try {
    in = new BufferedInputStream(new FileInputStream(file));
    properties.loadFromXML(in);
  } catch (Throwable t) {
    t.printStackTrace();
  } finally {
    if (in != null)
      try {
        in.close();
      } catch (IOException e) {
      }
  }
}

代码示例来源:origin: ankidroid/Anki-Android

public ProgressByteEntity(File file) {
  super();
  mLength = file.length();
  try {
    mInputStream = new BufferedInputStream(new FileInputStream(file));
  } catch (FileNotFoundException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: loklak/loklak_server

public static void gunzip(File source, File dest, boolean deleteSource) throws IOException {
  byte[] buffer = new byte[2^20];
  FileOutputStream out = new FileOutputStream(dest);
  GZIPInputStream in = new GZIPInputStream(new BufferedInputStream(new FileInputStream(source)));
  int l; while ((l = in.read(buffer)) > 0) out.write(buffer, 0, l);
  in.close(); out.close();
  if (deleteSource && dest.exists()) source.delete();
}

代码示例来源:origin: hankcs/HanLP

public void open(String fileName) throws IOException
{
  File file = new File(fileName);
  size = (int) file.length() / UNIT_SIZE;
  check = new int[size];
  base = new int[size];
  DataInputStream is = null;
  try
  {
    is = new DataInputStream(new BufferedInputStream(
        IOUtil.newInputStream(fileName), BUF_SIZE));
    for (int i = 0; i < size; i++)
    {
      base[i] = is.readInt();
      check[i] = is.readInt();
    }
  }
  finally
  {
    if (is != null)
      is.close();
  }
}

代码示例来源:origin: stackoverflow.com

InputStream input = new BufferedInputStream(connection.getInputStream());
  OutputStream output = new FileOutputStream("/sdcard/BarcodeScanner-debug.apk");
  input.close();
} catch (IOException e) {
  e.printStackTrace();

代码示例来源:origin: plantuml/plantuml

static public void copyToStream(File src, OutputStream os) throws IOException {
  final InputStream fis = new BufferedInputStream(new FileInputStream(src));
  final OutputStream fos = new BufferedOutputStream(os);
  copyInternal(fis, fos);
}

代码示例来源:origin: aporter/coursera-android

private void copyImageToMemory(File outFile) {
  try {
    BufferedOutputStream os = new BufferedOutputStream(
        new FileOutputStream(outFile));
    BufferedInputStream is = new BufferedInputStream(getResources()
        .openRawResource(R.raw.painter));
    copy(is, os);
  } catch (FileNotFoundException e) {
    Log.e(TAG, "FileNotFoundException");
  }
}

代码示例来源:origin: stackoverflow.com

URL url = new URL("http://www.yahoo.com/image_to_read.jpg");
InputStream in = new BufferedInputStream(url.openStream());
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int n = 0;
while (-1!=(n=in.read(buf)))
{
  out.write(buf, 0, n);
}
out.close();
in.close();
byte[] response = out.toByteArray();

代码示例来源:origin: redisson/redisson

final void process(Socket clnt) throws IOException {
  InputStream in = new BufferedInputStream(clnt.getInputStream());
  String cmd = readLine(in);
  logging(clnt.getInetAddress().getHostName(),
      new Date().toString(), cmd);
  while (skipLine(in) > 0){
  }
  OutputStream out = new BufferedOutputStream(clnt.getOutputStream());
  try {
    doReply(in, out, cmd);
  }
  catch (BadHttpRequest e) {
    replyError(out, e);
  }
  out.flush();
  in.close();
  out.close();
  clnt.close();
}

代码示例来源:origin: stackoverflow.com

BufferedInputStream bis = new BufferedInputStream(entity.getContent());
String filePath = "sample.txt";
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(filePath)));
int inByte;
while((inByte = bis.read()) != -1) bos.write(inByte);
bis.close();
bos.close();

代码示例来源:origin: hankcs/HanLP

public void open(String fileName) throws IOException
{
  File file = new File(fileName);
  size = (int) file.length() / UNIT_SIZE;
  check = new int[size];
  base = new int[size];
  DataInputStream is = null;
  try
  {
    is = new DataInputStream(new BufferedInputStream(
      new FileInputStream(file), BUF_SIZE));
    for (int i = 0; i < size; i++)
    {
      base[i] = is.readInt();
      check[i] = is.readInt();
    }
  }
  finally
  {
    if (is != null)
      is.close();
  }
}

代码示例来源:origin: apache/geode

private static DependencyGraph loadGraph(String filename) throws Exception {
 File file = new File(filename);
 if (!file.exists()) {
  System.err.println("unable to find " + filename);
  ExitCode.DEPENDENCY_GRAPH_FAILURE.doSystemExit();
 }
 ObjectInputStream ois =
   new DDObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
 DependencyGraph graph = (DependencyGraph) ois.readObject();
 return graph;
}

代码示例来源:origin: stackoverflow.com

public static int countLines(String filename) throws IOException {
  InputStream is = new BufferedInputStream(new FileInputStream(filename));
  try {
    byte[] c = new byte[1024];
    int count = 0;
    int readChars = 0;
    boolean empty = true;
    while ((readChars = is.read(c)) != -1) {
      empty = false;
      for (int i = 0; i < readChars; ++i) {
        if (c[i] == '\n') {
          ++count;
        }
      }
    }
    return (count == 0 && !empty) ? 1 : count;
  } finally {
    is.close();
  }
}

代码示例来源:origin: Activiti/Activiti

public static String readFileAsString(String filePath) {
 byte[] buffer = new byte[(int) getFile(filePath).length()];
 BufferedInputStream inputStream = null;
 try {
  inputStream = new BufferedInputStream(new FileInputStream(getFile(filePath)));
  inputStream.read(buffer);
 } catch (Exception e) {
  throw new ActivitiException("Couldn't read file " + filePath + ": " + e.getMessage());
 } finally {
  IoUtil.closeSilently(inputStream);
 }
 return new String(buffer);
}

代码示例来源:origin: pxb1988/dex2jar

@Override
  public InputStream _newInputStream() throws FileNotFoundException {
    return new BufferedInputStream(new FileInputStream(file));
  }
}

相关文章