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


Java DataOutputStream.size方法代码示例

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


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

示例1: report

import java.io.DataOutputStream; //导入方法依赖的package包/类
private static void report(final Sampler ss, final long time) {
    if (ss == null) {
        return;
    }
    class R implements Runnable {
        @Override
        public void run() {
            try {
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                DataOutputStream dos = new DataOutputStream(out);
                ss.stopAndWriteTo(dos);
                dos.close();
                if (dos.size() > 0) {
                    Object[] params = new Object[]{out.toByteArray(), time};
                    Logger.getLogger("org.netbeans.ui.performance").log(Level.CONFIG, "Slowness detected", params);
                } else {
                    LOG.log(Level.WARNING, "no snapshot taken"); // NOI18N
                }
            } catch (Exception ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    }
    RP.post(new R());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:TimableEventQueue.java

示例2: stop

import java.io.DataOutputStream; //导入方法依赖的package包/类
private synchronized void stop() throws Exception {
    long delta = System.currentTimeMillis() - time;

    Sampler ss = profiler;
    profiler = null;
    if (!profiling) {
        return;
    }
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(out);
        ss.stopAndWriteTo(dos);
        dos.close();
        if (dos.size() > 0) {
            Object[] params = new Object[]{out.toByteArray(), delta, "GoToType" };      //NOI18N
            Logger.getLogger("org.netbeans.ui.performance").log(Level.CONFIG, "Slowness detected", params); //NOI18N
        } else {
            LOGGER.log(Level.WARNING, "no snapshot taken"); // NOI18N
        }
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:GoToTypeAction.java

示例3: getCompressedSize

import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
 * Find the size of compressed data assuming that buffer will be compressed
 * using given algorithm.
 * @param algo compression algorithm
 * @param compressor compressor already requested from codec
 * @param inputBuffer Array to be compressed.
 * @param offset Offset to beginning of the data.
 * @param length Length to be compressed.
 * @return Size of compressed data in bytes.
 * @throws IOException
 */
public static int getCompressedSize(Algorithm algo, Compressor compressor,
    byte[] inputBuffer, int offset, int length) throws IOException {
  DataOutputStream compressedStream = new DataOutputStream(
      new IOUtils.NullOutputStream());
  if (compressor != null) {
    compressor.reset();
  }
  OutputStream compressingStream = null;

  try {
    compressingStream = algo.createCompressionStream(
        compressedStream, compressor, 0);

    compressingStream.write(inputBuffer, offset, length);
    compressingStream.flush();

    return compressedStream.size();
  } finally {
    if (compressingStream != null) compressingStream.close();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:EncodedDataBlock.java

示例4: stopImpl

import java.io.DataOutputStream; //导入方法依赖的package包/类
private void stopImpl(long now) throws Exception {
    long delta = now - time;
    LOG.log(Level.FINE, "Profiling stopped at {0}", now);
    int report = Integer.getInteger("org.netbeans.modules.editor.completion.slowness.report", 2000); // NOI18N
    if (delta < report) {
        LOG.log(Level.FINE, "Cancel profiling of {0}. Profiling {1}. Time {2} ms.", new Object[] { profiler, profiling, delta });
        if (profiler != null) {
            profiler.cancel();
        }
        return;
    }
    try {
        LOG.log(Level.FINE, "Obtaining snapshot for {0} ms.", delta);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(out);
        if (profiler != null) {
            profiler.stopAndWriteTo(dos);
        }
        dos.close();
        if (dos.size() > 0) {
            Object[] params = new Object[]{out.toByteArray(), delta, "CodeCompletion"};
            Logger.getLogger("org.netbeans.ui.performance").log(Level.CONFIG, "Slowness detected", params);
            LOG.log(Level.FINE, "Snapshot sent to UI logger. Size {0} bytes.", dos.size());
        } else {
            LOG.log(Level.WARNING, "No snapshot taken"); // NOI18N
        }
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:CompletionImplProfile.java

示例5: releaseCompressingStream

import java.io.DataOutputStream; //导入方法依赖的package包/类
private int releaseCompressingStream(final DataOutputStream dos)
throws IOException {
  dos.flush();
  this.compressAlgo.returnCompressor(this.compressor);
  this.compressor = null;
  return dos.size();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:IndexFile.java

示例6: getMidKeyMetadata

import java.io.DataOutputStream; //导入方法依赖的package包/类
/**
 * Used when writing the root block index of a multi-level block index.
 * Serializes additional information allowing to efficiently identify the
 * mid-key.
 *
 * @return a few serialized fields for finding the mid-key
 * @throws IOException if could not create metadata for computing mid-key
 */
public byte[] getMidKeyMetadata() throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream(
      MID_KEY_METADATA_SIZE);
  DataOutputStream baosDos = new DataOutputStream(baos);
  long totalNumSubEntries = numSubEntriesAt.get(blockKeys.size() - 1);
  if (totalNumSubEntries == 0) {
    throw new IOException("No leaf-level entries, mid-key unavailable");
  }
  long midKeySubEntry = (totalNumSubEntries - 1) / 2;
  int midKeyEntry = getEntryBySubEntry(midKeySubEntry);

  baosDos.writeLong(blockOffsets.get(midKeyEntry));
  baosDos.writeInt(onDiskDataSizes.get(midKeyEntry));

  long numSubEntriesBefore = midKeyEntry > 0
      ? numSubEntriesAt.get(midKeyEntry - 1) : 0;
  long subEntryWithinEntry = midKeySubEntry - numSubEntriesBefore;
  if (subEntryWithinEntry < 0 || subEntryWithinEntry > Integer.MAX_VALUE)
  {
    throw new IOException("Could not identify mid-key index within the "
        + "leaf-level block containing mid-key: out of range ("
        + subEntryWithinEntry + ", numSubEntriesBefore="
        + numSubEntriesBefore + ", midKeySubEntry=" + midKeySubEntry
        + ")");
  }

  baosDos.writeInt((int) subEntryWithinEntry);

  if (baosDos.size() != MID_KEY_METADATA_SIZE) {
    throw new IOException("Could not write mid-key metadata: size=" +
        baosDos.size() + ", correct size: " + MID_KEY_METADATA_SIZE);
  }

  // Close just to be good citizens, although this has no effect.
  baos.close();

  return baos.toByteArray();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:47,代码来源:HFileBlockIndex.java

示例7: stopImpl

import java.io.DataOutputStream; //导入方法依赖的package包/类
private void stopImpl() throws Exception {
    final long now = System.currentTimeMillis();
    long delta = now - time;
    LOG.log(Level.FINE, "Profiling stopped at {0}", now);
    int report = Integer.getInteger("org.netbeans.modules.parsing.api.taskcancel.slowness.report", 1000); // NOI18N
    if (delta < report) {
        LOG.finest("CANCEL");  //NOI18N
        if (profiler != null) {
            profiler.cancel();
            LOG.log(
                Level.FINE,
                "Cancel profiling of {0}. Profiling {1}. Time {2} ms.",     //NOI18N
                new Object[] {
                    profiler,
                    profiling,
                    delta
                });
        }
        return;
    }
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(out);
        LOG.finest("LOGGED");  //NOI18N
        if (profiler != null) {
            profiler.stopAndSnapshot(dos);
            LOG.log(
                Level.FINE,
                "Obtaining snapshot for {0} ms.",   //NOI18N
                delta);
        }
        dos.close();
        if (dos.size() > 0) {
            Object[] params = new Object[]{out.toByteArray(), delta, "ParserResultTask-cancel"};    //NOI18N
            Logger.getLogger("org.netbeans.ui.performance").log(Level.CONFIG, "Slowness detected", params); //NOI18N
            LOG.log(Level.FINE, "Snapshot sent to UI logger. Size {0} bytes.", dos.size()); //NOI18N
        } else {
            LOG.log(Level.WARNING, "No snapshot taken"); // NOI18N
        }
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:SelfProfile.java


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