List of usage examples for java.io DataOutput write
void write(byte b[]) throws IOException;
b
. From source file:bobs.is.compress.sevenzip.SevenZOutputFile.java
private void writeFilesInfo(final DataOutput header) throws IOException { header.write(NID.kFilesInfo); writeUint64(header, files.size());/*from ww w. ja v a 2 s . c o m*/ writeFileEmptyStreams(header); writeFileEmptyFiles(header); writeFileAntiItems(header); writeFileNames(header); writeFileCTimes(header); writeFileATimes(header); writeFileMTimes(header); writeFileWindowsAttributes(header); header.write(NID.kEnd); }
From source file:bobs.is.compress.sevenzip.SevenZOutputFile.java
private void writeFileNames(final DataOutput header) throws IOException { header.write(NID.kName); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final DataOutputStream out = new DataOutputStream(baos); out.write(0);//from ww w . j a v a2 s.co m for (final SevenZArchiveEntry entry : files) { out.write(entry.getName().getBytes("UTF-16LE")); out.writeShort(0); } out.flush(); final byte[] contents = baos.toByteArray(); writeUint64(header, contents.length); header.write(contents); }
From source file:bobs.is.compress.sevenzip.SevenZOutputFile.java
private void writePackInfo(final DataOutput header) throws IOException { header.write(NID.kPackInfo); writeUint64(header, 0);//from www . ja v a 2 s . c o m writeUint64(header, 0xffffFFFFL & numNonEmptyStreams); header.write(NID.kSize); for (final SevenZArchiveEntry entry : files) { if (entry.hasStream()) { writeUint64(header, entry.getCompressedSize()); } } header.write(NID.kCRC); header.write(1); // "allAreDefined" == true for (final SevenZArchiveEntry entry : files) { if (entry.hasStream()) { header.writeInt(Integer.reverseBytes((int) entry.getCompressedCrcValue())); } } header.write(NID.kEnd); }
From source file:bobs.is.compress.sevenzip.SevenZOutputFile.java
private void writeUnpackInfo(final DataOutput header) throws IOException { header.write(NID.kUnpackInfo); header.write(NID.kFolder);//from ww w . ja v a2 s . com writeUint64(header, numNonEmptyStreams); header.write(0); for (final SevenZArchiveEntry entry : files) { if (entry.hasStream()) { writeFolder(header, entry); } } header.write(NID.kCodersUnpackSize); for (final SevenZArchiveEntry entry : files) { if (entry.hasStream()) { final long[] moreSizes = additionalSizes.get(entry); if (moreSizes != null) { for (final long s : moreSizes) { writeUint64(header, s); } } writeUint64(header, entry.getSize()); } } header.write(NID.kCRC); header.write(1); // "allAreDefined" == true for (final SevenZArchiveEntry entry : files) { if (entry.hasStream()) { header.writeInt(Integer.reverseBytes((int) entry.getCrcValue())); } } header.write(NID.kEnd); }
From source file:com.nearinfinity.blur.mapreduce.BlurTask.java
@Override public void write(DataOutput output) throws IOException { output.writeLong(_maxRecordCount);/*from ww w . j a va 2s. c o m*/ output.writeInt(_ramBufferSizeMB); output.writeBoolean(_optimize); writeString(output, _indexingType.name()); ByteArrayOutputStream os = new ByteArrayOutputStream(); TIOStreamTransport trans = new TIOStreamTransport(os); TBinaryProtocol protocol = new TBinaryProtocol(trans); try { _tableDescriptor.write(protocol); } catch (TException e) { throw new IOException(e); } os.close(); byte[] bs = os.toByteArray(); output.writeInt(bs.length); output.write(bs); }
From source file:bobs.is.compress.sevenzip.SevenZOutputFile.java
private void writeStreamsInfo(final DataOutput header) throws IOException { if (numNonEmptyStreams > 0) { writePackInfo(header);/*from w w w .java 2 s .c om*/ writeUnpackInfo(header); } writeSubStreamsInfo(header); header.write(NID.kEnd); }
From source file:eu.stratosphere.types.StringValue.java
@Override public void write(final DataOutput out) throws IOException { int len = this.len; // write the length, variable-length encoded while (len >= HIGH_BIT) { out.write(len | HIGH_BIT); len >>>= 7;/*from w w w. j a v a 2s . com*/ } out.write(len); // write the char data, variable length encoded for (int i = 0; i < this.len; i++) { int c = this.value[i]; while (c >= HIGH_BIT) { out.write(c | HIGH_BIT); c >>>= 7; } out.write(c); } }
From source file:dk.statsbiblioteket.util.LineReaderTest.java
public void writeSample(DataOutput out) throws Exception { out.writeInt(12345);//from www. ja v a2 s . c o m out.writeInt(-87); out.writeLong(123456789L); out.write("Hello World!\n".getBytes("utf-8")); out.write("Another world\n".getBytes("utf-8")); out.writeFloat(0.5f); out.writeBoolean(true); out.writeBoolean(false); out.writeByte(12); out.writeByte(-12); out.write(129); out.writeShort(-4567); out.writeBytes("ASCII"); }
From source file:bobs.is.compress.sevenzip.SevenZOutputFile.java
private void writeBits(final DataOutput header, final BitSet bits, final int length) throws IOException { int cache = 0; int shift = 7; for (int i = 0; i < length; i++) { cache |= ((bits.get(i) ? 1 : 0) << shift); if (--shift < 0) { header.write(cache); shift = 7;/*from w w w. j a va2s . c o m*/ cache = 0; } } if (shift != 7) { header.write(cache); } }
From source file:bobs.is.compress.sevenzip.SevenZOutputFile.java
private void writeFileATimes(final DataOutput header) throws IOException { int numAccessDates = 0; for (final SevenZArchiveEntry entry : files) { if (entry.getHasAccessDate()) { ++numAccessDates;/*from w w w . j a v a 2s. c o m*/ } } if (numAccessDates > 0) { header.write(NID.kATime); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final DataOutputStream out = new DataOutputStream(baos); if (numAccessDates != files.size()) { out.write(0); final BitSet aTimes = new BitSet(files.size()); for (int i = 0; i < files.size(); i++) { aTimes.set(i, files.get(i).getHasAccessDate()); } writeBits(out, aTimes, files.size()); } else { out.write(1); // "allAreDefined" == true } out.write(0); for (final SevenZArchiveEntry entry : files) { if (entry.getHasAccessDate()) { out.writeLong(Long.reverseBytes(SevenZArchiveEntry.javaTimeToNtfsTime(entry.getAccessDate()))); } } out.flush(); final byte[] contents = baos.toByteArray(); writeUint64(header, contents.length); header.write(contents); } }