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


Java ByteSink.openBufferedStream方法代码示例

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


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

示例1: writeBinary

import com.google.common.io.ByteSink; //导入方法依赖的package包/类
public static void writeBinary(OffsetIndex offsetIndex, ByteSink sink) throws IOException {
  final DataOutputStream out = new DataOutputStream(sink.openBufferedStream());

  boolean threw = true;
  try {
    out.writeInt(offsetIndex.keySet().size());
    // use a fixed key order to be diff-friendly.
    final Iterable<Symbol> keyOrder =
        Ordering.usingToString().immutableSortedCopy(offsetIndex.keySet());
    for (final Symbol key : keyOrder) {
      out.writeUTF(key.asString());
      // get is safe because we are iterating over the mapping's key set
      final OffsetRange<ByteOffset> range = offsetIndex.byteOffsetsOf(key).get();
      out.writeInt(range.startInclusive().asInt());
      out.writeInt(range.endInclusive().asInt());
    }
    threw = false;
  } finally {
    Closeables.close(out, threw);
  }

}
 
开发者ID:BBN-E,项目名称:bue-common-open,代码行数:23,代码来源:OffsetIndices.java

示例2: stream

import com.google.common.io.ByteSink; //导入方法依赖的package包/类
final void stream(
    ByteSource input, ByteSink output, ByteSink error)
throws IOException, MojoExecutionException {
  try (InputStream in = input.openBufferedStream()) {
    try (OutputStream out = output.openBufferedStream()) {
      try (PrintStream pout = new PrintStream(out, true, "UTF-8")) {
        try (OutputStream err = error.openBufferedStream()) {
          try (PrintStream perr = new PrintStream(err, true, "UTF-8")) {
            stream(in, pout, perr);
          }
        }
      }
    }
  }
}
 
开发者ID:mikesamuel,项目名称:closure-maven-plugin,代码行数:16,代码来源:Streamer.java

示例3: writeBinaryIntArray

import com.google.common.io.ByteSink; //导入方法依赖的package包/类
public static void writeBinaryIntArray(final int[] arr,
    final ByteSink outSup) throws IOException {
  try (OutputStream out = outSup.openBufferedStream()) {
    try (DataOutputStream dos = new DataOutputStream(out)) {
      dos.writeInt(arr.length);
      for (final int x : arr) {
        dos.writeInt(x);
      }
    }
  }
}
 
开发者ID:BBN-E,项目名称:bue-common-open,代码行数:12,代码来源:FileUtils.java

示例4: serializeTo

import com.google.common.io.ByteSink; //导入方法依赖的package包/类
public void serializeTo(final Object o, final ByteSink out) throws IOException {
  final RootObject rootObj = RootObject.forObject(o);
  final OutputStream bufStream = out.openBufferedStream();
  mapper.writeValue(bufStream, rootObj);
  bufStream.close();
}
 
开发者ID:BBN-E,项目名称:bue-common-open,代码行数:7,代码来源:JacksonSerializer.java

示例5: writeFstToBinaryFile

import com.google.common.io.ByteSink; //导入方法依赖的package包/类
public static void writeFstToBinaryFile(Fst fst, File file) throws IOException {
  ByteSink bs = Files.asByteSink(file);
  try (ObjectOutputStream oos = new ObjectOutputStream(new GZIPOutputStream(bs.openBufferedStream()))) {
    writeFstToBinaryStream(fst, oos);
  }
}
 
开发者ID:steveash,项目名称:jopenfst,代码行数:7,代码来源:FstInputOutput.java

示例6: writeTo

import com.google.common.io.ByteSink; //导入方法依赖的package包/类
public static <T> void writeTo(T model, File outputFile) throws IOException {
  ByteSink sink = Files.asByteSink(outputFile);
  try (ObjectOutputStream oos = new ObjectOutputStream(sink.openBufferedStream())) {
    oos.writeObject(model);
  }
}
 
开发者ID:steveash,项目名称:jg2p,代码行数:7,代码来源:ReadWrite.java


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