List of usage examples for java.io DataOutputStream writeInt
public final void writeInt(int v) throws IOException
int
to the underlying output stream as four bytes, high byte first. From source file:sk.baka.aedict.indexer.SodMain.java
private void createPackedFile() throws IOException { System.out.println("Packaging " + pngLengths.size() + " pngs"); final DataOutputStream out = new DataOutputStream( new GZIPOutputStream(new FileOutputStream("target/sod.dat.gz"))); try {/*from w w w . j a va2s. c o m*/ // write index table int offset = pngLengths.size() * 6 + 4; out.writeInt(pngLengths.size()); final List<Character> kanjis = new ArrayList<Character>(pngLengths.keySet()); for (final Character kanji : kanjis) { out.writeChar(kanji); out.writeInt(offset); offset += (int) pngLengths.get(kanji).length(); } // write png contents for (final Character kanji : kanjis) { final InputStream in = new FileInputStream(pngLengths.get(kanji)); try { IOUtils.copy(in, out); } finally { IOUtils.closeQuietly(in); } } } finally { IOUtils.closeQuietly(out); } }
From source file:org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager.java
private synchronized void saveAllKeys(DataOutputStream out) throws IOException { out.writeInt(allKeys.size()); Iterator<Integer> iter = allKeys.keySet().iterator(); while (iter.hasNext()) { Integer key = iter.next(); allKeys.get(key).write(out);/*from w w w . j a v a 2 s . co m*/ } }
From source file:cn.edu.wyu.documentviewer.model.DocumentInfo.java
@Override public void write(DataOutputStream out) throws IOException { out.writeInt(VERSION_SPLIT_URI); DurableUtils.writeNullableString(out, authority); DurableUtils.writeNullableString(out, documentId); DurableUtils.writeNullableString(out, mimeType); DurableUtils.writeNullableString(out, displayName); out.writeLong(lastModified);/*from w ww . j a va 2s.c om*/ out.writeInt(flags); DurableUtils.writeNullableString(out, summary); out.writeLong(size); out.writeInt(icon); }
From source file:org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenSecretManager.java
/** * Private helper methods to save delegation keys and tokens in fsimage *//* w w w. ja v a 2s. co m*/ private synchronized void saveCurrentTokens(DataOutputStream out) throws IOException { out.writeInt(currentTokens.size()); Iterator<DelegationTokenIdentifier> iter = currentTokens.keySet().iterator(); while (iter.hasNext()) { DelegationTokenIdentifier id = iter.next(); id.write(out); DelegationTokenInformation info = currentTokens.get(id); out.writeLong(info.getRenewDate()); } }
From source file:org.openmrs.module.odkconnector.serialization.serializer.ListSerializer.java
/** * Write the data to the output stream.//from w ww.ja v a 2 s . c om * * @param stream the output stream * @param data the data that need to be written to the output stream * @throws java.io.IOException thrown when the writing process encounter is failing */ @Override public void write(final OutputStream stream, final Object data) throws IOException { DataOutputStream outputStream = new DataOutputStream(stream); List list = null; if (ClassUtils.isAssignable(data.getClass(), List.class)) list = (List) data; if (list == null || CollectionUtils.isEmpty(list)) outputStream.writeInt(Serializer.ZERO); else { outputStream.writeInt(list.size()); for (Object object : list) { Serializer serializer = HandlerUtil.getPreferredHandler(Serializer.class, object.getClass()); serializer.write(outputStream, object); } outputStream.flush(); } }
From source file:org.dice_research.topicmodeling.io.stream.DocumentSupplierSerializer.java
protected void writeDocument(DataOutputStream dout, Document document) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oout = new ObjectOutputStream(bout); oout.writeObject(document);//from w w w. j a v a2 s . co m oout.close(); dout.writeInt(bout.size()); bout.writeTo(dout); }
From source file:com.opensoc.json.serialization.JSONKafkaSerializer.java
public void putArray(DataOutputStream data, JSONArray array) throws IOException { data.writeByte(JSONKafkaSerializer.JSONArrayID); data.writeInt(array.size()); for (Object o : array) putObject(data, o);/*from www . j a va 2s . c o m*/ }
From source file:org.getspout.spout.packet.PacketAddonData.java
public void writeData(DataOutputStream output) throws IOException { PacketUtil.writeString(output, (AddonPacket.getPacketId(packet.getClass()))); output.writeInt(data.length); output.writeBoolean(compressed);//from w ww.j av a 2 s. co m output.write(data); }
From source file:org.nuxeo.osgi.BundleIdGenerator.java
public synchronized void store(File file) throws IOException { DataOutputStream out = null; try {/*from w w w. j ava 2 s . c o m*/ out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file))); out.writeLong(count); int size = ids.size(); out.writeInt(size); for (Map.Entry<String, Long> entry : ids.entrySet()) { out.writeUTF(entry.getKey()); out.writeLong(entry.getValue()); } } finally { if (out != null) { out.close(); } } }
From source file:RetrieveAllMIDlet.java
public byte[] changeToByteArray() { byte[] data = null; try {/*w w w.java2s .c o m*/ ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); dos.writeUTF(name); dos.writeInt(chineseScore); dos.writeInt(englishScore); dos.writeInt(mathScore); data = baos.toByteArray(); baos.close(); dos.close(); } catch (Exception e) { } return data; }