本文整理匯總了Java中org.apache.commons.io.output.NullOutputStream.NULL_OUTPUT_STREAM屬性的典型用法代碼示例。如果您正苦於以下問題:Java NullOutputStream.NULL_OUTPUT_STREAM屬性的具體用法?Java NullOutputStream.NULL_OUTPUT_STREAM怎麽用?Java NullOutputStream.NULL_OUTPUT_STREAM使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.apache.commons.io.output.NullOutputStream
的用法示例。
在下文中一共展示了NullOutputStream.NULL_OUTPUT_STREAM屬性的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testOutputStreamBigDataBigChunks
@Test
public void testOutputStreamBigDataBigChunks() {
// don't run if the JVM doesn't have enough memory
Assume.assumeTrue("testOutputStreamBigDataBigChunks: JVM has enough memory (~4GB)",
Runtime.getRuntime().maxMemory() > 4e9);
final int dataSize = (Integer.MAX_VALUE - 8) /*=max array size*/ - 5 /*=array header size*/;
byte[] data = new byte[dataSize - 1];
AutoBuffer ab = new AutoBuffer(NullOutputStream.NULL_OUTPUT_STREAM, false);
// make sure the buffer can take the full array
ab.putA1(data);
// now try to stream 1TB of data through the buffer
for (int i = 0; i < 512; i++) {
if (i % 10 == 0)
System.out.println(i);
ab.putA1(data);
}
ab.close();
}
示例2: computeTrailerSizeByVersion
private static int[] computeTrailerSizeByVersion() {
int versionToSize[] = new int[HFile.MAX_FORMAT_VERSION + 1];
for (int version = HFile.MIN_FORMAT_VERSION;
version <= HFile.MAX_FORMAT_VERSION;
++version) {
FixedFileTrailer fft = new FixedFileTrailer(version, HFileBlock.MINOR_VERSION_NO_CHECKSUM);
DataOutputStream dos = new DataOutputStream(NullOutputStream.NULL_OUTPUT_STREAM);
try {
fft.serialize(dos);
} catch (IOException ex) {
// The above has no reason to fail.
throw new RuntimeException(ex);
}
versionToSize[version] = dos.size();
}
return versionToSize;
}
示例3: getStream
/**
* @return The stream to write to after the entry signal was received.
*/
public OutputStream getStream() {
if(null == stream) {
// Nothing to write
return NullOutputStream.NULL_OUTPUT_STREAM;
}
return stream;
}
示例4: testOfflineImageViewer
/**
* Test if the OfflineImageViewerPB can correctly parse a fsimage containing
* snapshots
*/
@Test
public void testOfflineImageViewer() throws Exception {
runTestSnapshot(1);
// retrieve the fsimage. Note that we already save namespace to fsimage at
// the end of each iteration of runTestSnapshot.
File originalFsimage = FSImageTestUtil.findLatestImageFile(
FSImageTestUtil.getFSImage(
cluster.getNameNode()).getStorage().getStorageDir(0));
assertNotNull("Didn't generate or can't find fsimage", originalFsimage);
PrintStream o = new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM);
PBImageXmlWriter v = new PBImageXmlWriter(new Configuration(), o);
v.visit(new RandomAccessFile(originalFsimage, "r"));
}
示例5: testTruncatedFSImage
@Test(expected = IOException.class)
public void testTruncatedFSImage() throws IOException {
File truncatedFile = folder.newFile();
PrintStream output = new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM);
copyPartOfFile(originalFsimage, truncatedFile);
new FileDistributionCalculator(new Configuration(), 0, 0, output)
.visit(new RandomAccessFile(truncatedFile, "r"));
}
示例6: testOutputStreamBigDataSmallChunks
@Test
public void testOutputStreamBigDataSmallChunks() {
final int dataSize = 100 * 1024;
byte[] data = new byte[dataSize - 1];
AutoBuffer ab = new AutoBuffer(NullOutputStream.NULL_OUTPUT_STREAM, false);
// make sure the buffer can take full array
ab.putA1(data);
// try to stream 1TB of data made of small chunks through AutoBuffer
for (int i = 0; i < 1e12 / dataSize; i++)
ab.putA1(data);
ab.close();
}
示例7: testOutputStreamSmallData
@Test
public void testOutputStreamSmallData() {
final int dataSize = 100 * 1024;
byte[] data = new byte[dataSize];
AutoBuffer ab = new AutoBuffer(NullOutputStream.NULL_OUTPUT_STREAM, false);
// stream bite-size data to AutoBuffer
for (int i = 0; i < Integer.MAX_VALUE / dataSize; i++)
ab.putA1(data);
ab.close();
}
示例8: HashOrderDependent
public HashOrderDependent(){
try{
digest = MessageDigest.getInstance("MD5");
} catch ( Exception ex ) {
throw new RuntimeException(ex);
}
digestOutputStream = new DigestOutputStream(NullOutputStream.NULL_OUTPUT_STREAM, digest);
dataOutputStream = new DataOutputStream(digestOutputStream);
}
示例9: CapturedStreamOutput
/**
* @param settings Settings that define what to capture.
* @param processStream Stream to capture output.
* @param standardStream Stream to write debug output.
*/
public CapturedStreamOutput(OutputStreamSettings settings, InputStream processStream, PrintStream standardStream) {
this.processStream = processStream;
int bufferSize = settings.getBufferSize();
this.bufferStream = (bufferSize < 0) ? new ByteArrayOutputStream() : new ByteArrayOutputStream(bufferSize);
for (StreamLocation location : settings.getStreamLocations()) {
OutputStream outputStream;
switch (location) {
case Buffer:
if (bufferSize < 0) {
outputStream = this.bufferStream;
} else {
outputStream = new HardThresholdingOutputStream(bufferSize) {
@Override
protected OutputStream getStream() {
return bufferTruncated ? NullOutputStream.NULL_OUTPUT_STREAM : bufferStream;
}
@Override
protected void thresholdReached() {
bufferTruncated = true;
}
};
}
break;
case File:
try {
outputStream = new FileOutputStream(settings.getOutputFile(), settings.isAppendFile());
} catch (IOException e) {
throw new UserException.BadInput(e.getMessage());
}
break;
case Standard:
outputStream = standardStream;
break;
default:
throw new GATKException("Unexpected stream location: " + location);
}
this.outputStreams.put(location, outputStream);
}
}
示例10: NullObjectOutputStream
NullObjectOutputStream() throws IOException {
super(NullOutputStream.NULL_OUTPUT_STREAM);
}
示例11: CustomTrigWriter
public CustomTrigWriter(Set<String> usedPrefixes) {
super(NullOutputStream.NULL_OUTPUT_STREAM);
this.usedPrefixes = usedPrefixes;
}
示例12: redirectOutput
/**
* Redirects the process' output stream to given output stream.
* If this method is invoked multiple times each call overwrites the previous.
* Use {@link #redirectOutputAlsoTo(OutputStream)} if you want to redirect the output to multiple streams.
*
* @param output output stream where the process output is redirected to (<code>null</code> means {@link NullOutputStream} which acts like a <code>/dev/null</code>).
* @return This process executor.
*/
public ProcessExecutor redirectOutput(OutputStream output) {
if (output == null)
output = NullOutputStream.NULL_OUTPUT_STREAM;
PumpStreamHandler pumps = pumps();
// Only set the output stream handler, preserve the same error stream handler
return streams(new PumpStreamHandler(output, pumps == null ? null : pumps.getErr(), pumps == null ? null : pumps.getInput()));
}
示例13: redirectError
/**
* Redirects the process' error stream to given output stream.
* If this method is invoked multiple times each call overwrites the previous.
* Use {@link #redirectErrorAlsoTo(OutputStream)} if you want to redirect the error to multiple streams.
* <p>
* Calling this method automatically disables merging the process error stream to its output stream.
* </p>
*
* @param output output stream where the process error is redirected to (<code>null</code> means {@link NullOutputStream} which acts like a <code>/dev/null</code>).
* @return This process executor.
*/
public ProcessExecutor redirectError(OutputStream output) {
if (output == null)
output = NullOutputStream.NULL_OUTPUT_STREAM;
PumpStreamHandler pumps = pumps();
// Only set the error stream handler, preserve the same output stream handler
streams(new PumpStreamHandler(pumps == null ? null : pumps.getOut(), output, pumps == null ? null : pumps.getInput()));
redirectErrorStream(false);
return this;
}