Java Code Examples for java.io.DataOutputStream#writeChars()
The following examples show how to use
java.io.DataOutputStream#writeChars() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FontConfiguration.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void saveBinary(OutputStream out) throws IOException { sanityCheck(); DataOutputStream dataOut = new DataOutputStream(out); writeShortTable(dataOut, head); writeShortTable(dataOut, table_scriptIDs); writeShortTable(dataOut, table_scriptFonts); writeShortTable(dataOut, table_elcIDs); writeShortTable(dataOut, table_sequences); writeShortTable(dataOut, table_fontfileNameIDs); writeShortTable(dataOut, table_componentFontNameIDs); writeShortTable(dataOut, table_filenames); writeShortTable(dataOut, table_awtfontpaths); writeShortTable(dataOut, table_exclusions); writeShortTable(dataOut, table_proportionals); writeShortTable(dataOut, table_scriptFontsMotif); writeShortTable(dataOut, table_alphabeticSuffix); writeShortTable(dataOut, table_stringIDs); //stringTable dataOut.writeChars(new String(table_stringTable)); out.close(); if (verbose) { dump(); } }
Example 2
Source File: FontConfiguration.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void saveBinary(OutputStream out) throws IOException { sanityCheck(); DataOutputStream dataOut = new DataOutputStream(out); writeShortTable(dataOut, head); writeShortTable(dataOut, table_scriptIDs); writeShortTable(dataOut, table_scriptFonts); writeShortTable(dataOut, table_elcIDs); writeShortTable(dataOut, table_sequences); writeShortTable(dataOut, table_fontfileNameIDs); writeShortTable(dataOut, table_componentFontNameIDs); writeShortTable(dataOut, table_filenames); writeShortTable(dataOut, table_awtfontpaths); writeShortTable(dataOut, table_exclusions); writeShortTable(dataOut, table_proportionals); writeShortTable(dataOut, table_scriptFontsMotif); writeShortTable(dataOut, table_alphabeticSuffix); writeShortTable(dataOut, table_stringIDs); //stringTable dataOut.writeChars(new String(table_stringTable)); out.close(); if (verbose) { dump(); } }
Example 3
Source File: FontConfiguration.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void saveBinary(OutputStream out) throws IOException { sanityCheck(); DataOutputStream dataOut = new DataOutputStream(out); writeShortTable(dataOut, head); writeShortTable(dataOut, table_scriptIDs); writeShortTable(dataOut, table_scriptFonts); writeShortTable(dataOut, table_elcIDs); writeShortTable(dataOut, table_sequences); writeShortTable(dataOut, table_fontfileNameIDs); writeShortTable(dataOut, table_componentFontNameIDs); writeShortTable(dataOut, table_filenames); writeShortTable(dataOut, table_awtfontpaths); writeShortTable(dataOut, table_exclusions); writeShortTable(dataOut, table_proportionals); writeShortTable(dataOut, table_scriptFontsMotif); writeShortTable(dataOut, table_alphabeticSuffix); writeShortTable(dataOut, table_stringIDs); //stringTable dataOut.writeChars(new String(table_stringTable)); out.close(); if (verbose) { dump(); } }
Example 4
Source File: JsonWriter.java From Azzet with Open Software License 3.0 | 6 votes |
public static JsonWriter forOutputStream( final OutputStream oos ) { final DataOutputStream dos = new DataOutputStream( oos ); return new JsonWriter() { public void write( String s ) throws IOException { dos.writeChars( s ); } public void write( char c ) throws IOException { dos.writeChar( c ); } }; }
Example 5
Source File: FontConfiguration.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static void saveBinary(OutputStream out) throws IOException { sanityCheck(); DataOutputStream dataOut = new DataOutputStream(out); writeShortTable(dataOut, head); writeShortTable(dataOut, table_scriptIDs); writeShortTable(dataOut, table_scriptFonts); writeShortTable(dataOut, table_elcIDs); writeShortTable(dataOut, table_sequences); writeShortTable(dataOut, table_fontfileNameIDs); writeShortTable(dataOut, table_componentFontNameIDs); writeShortTable(dataOut, table_filenames); writeShortTable(dataOut, table_awtfontpaths); writeShortTable(dataOut, table_exclusions); writeShortTable(dataOut, table_proportionals); writeShortTable(dataOut, table_scriptFontsMotif); writeShortTable(dataOut, table_alphabeticSuffix); writeShortTable(dataOut, table_stringIDs); //stringTable dataOut.writeChars(new String(table_stringTable)); out.close(); if (verbose) { dump(); } }
Example 6
Source File: FontConfiguration.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void saveBinary(OutputStream out) throws IOException { sanityCheck(); DataOutputStream dataOut = new DataOutputStream(out); writeShortTable(dataOut, head); writeShortTable(dataOut, table_scriptIDs); writeShortTable(dataOut, table_scriptFonts); writeShortTable(dataOut, table_elcIDs); writeShortTable(dataOut, table_sequences); writeShortTable(dataOut, table_fontfileNameIDs); writeShortTable(dataOut, table_componentFontNameIDs); writeShortTable(dataOut, table_filenames); writeShortTable(dataOut, table_awtfontpaths); writeShortTable(dataOut, table_exclusions); writeShortTable(dataOut, table_proportionals); writeShortTable(dataOut, table_scriptFontsMotif); writeShortTable(dataOut, table_alphabeticSuffix); writeShortTable(dataOut, table_stringIDs); //stringTable dataOut.writeChars(new String(table_stringTable)); out.close(); if (verbose) { dump(); } }
Example 7
Source File: LibraryPageScreen.java From Alite with GNU General Public License v3.0 | 6 votes |
@Override public void saveScreenState(DataOutputStream dos) throws IOException { Toc toc = Toc.read(game.getFileIO().readPrivateFile("library/toc.xml"), game.getFileIO()); TocEntry[] entries = toc.getEntries(); int index = findTocEntryIndex(entries, tocEntry.getName(), 0); if (index < 0) { index = 0; } dos.writeInt(index); dos.writeInt(currentFilter == null ? 0 : currentFilter.length()); if (currentFilter != null) { dos.writeChars(currentFilter); } dos.writeInt(yPosition); }
Example 8
Source File: QuantityPadScreen.java From Alite with GNU General Public License v3.0 | 6 votes |
@Override public void saveScreenState(DataOutputStream dos) throws IOException { dos.writeInt(xPos); dos.writeInt(yPos); dos.writeInt(row); dos.writeInt(column); dos.writeInt(maxAmountString == null ? 0 : maxAmountString.length()); if (maxAmountString != null) { dos.writeChars(maxAmountString); } dos.writeInt(currentAmountString == null ? 0 : currentAmountString.length()); if (currentAmountString != null) { dos.writeChars(currentAmountString); } marketScreen.saveScreenState(dos); }
Example 9
Source File: TestDelegatingInputFormat.java From hadoop with Apache License 2.0 | 5 votes |
static Path getPath(final String location, final FileSystem fs) throws IOException { Path path = new Path(location); // create a multi-block file on hdfs DataOutputStream out = fs.create(path, true, 4096, (short) 2, 512, null); for (int i = 0; i < 1000; ++i) { out.writeChars("Hello\n"); } out.close(); return path; }
Example 10
Source File: IOUtilities.java From Open-Realms-of-Stars with GNU General Public License v2.0 | 5 votes |
/** * Writes string into DataOutputStream. First 4 octets tell string length * then each character is written with 2 octets * @param os the output stream * @param str the string that os gets * @throws IOException if there is any problem with DataOutputStream */ public static void writeString(final DataOutputStream os, final String str) throws IOException { if (str != null) { os.writeInt(str.length()); os.writeChars(str); } else { os.writeInt(0); } }
Example 11
Source File: TestDelegatingInputFormat.java From big-c with Apache License 2.0 | 5 votes |
static Path getPath(final String location, final FileSystem fs) throws IOException { Path path = new Path(location); // create a multi-block file on hdfs DataOutputStream out = fs.create(path, true, 4096, (short) 2, 512, null); for (int i = 0; i < 1000; ++i) { out.writeChars("Hello\n"); } out.close(); return path; }
Example 12
Source File: TestMRCJCFileInputFormat.java From hadoop with Apache License 2.0 | 5 votes |
private void createInputs(FileSystem fs, Path inDir, String fileName) throws IOException, TimeoutException, InterruptedException { // create a multi-block file on hdfs Path path = new Path(inDir, fileName); final short replication = 2; DataOutputStream out = fs.create(path, true, 4096, replication, 512, null); for(int i=0; i < 1000; ++i) { out.writeChars("Hello\n"); } out.close(); System.out.println("Wrote file"); DFSTestUtil.waitReplication(fs, path, replication); }
Example 13
Source File: InventoryScreen.java From Alite with GNU General Public License v3.0 | 5 votes |
@Override public void saveScreenState(DataOutputStream dos) throws IOException { dos.writeByte(selection == null ? 0 : selection.getName().length()); if (selection != null) { dos.writeChars(selection.getName()); } }
Example 14
Source File: TestDelegatingInputFormat.java From hadoop-gpu with Apache License 2.0 | 5 votes |
static Path getPath(final String location, final FileSystem fs) throws IOException { Path path = new Path(location); // create a multi-block file on hdfs DataOutputStream out = fs.create(path, true, 4096, (short) 2, 512, null); for (int i = 0; i < 1000; ++i) { out.writeChars("Hello\n"); } out.close(); return path; }
Example 15
Source File: TestDelegatingInputFormat.java From RDFS with Apache License 2.0 | 5 votes |
static Path getPath(final String location, final FileSystem fs) throws IOException { Path path = new Path(location); // create a multi-block file on hdfs DataOutputStream out = fs.create(path, true, 4096, (short) 2, 512, null); for (int i = 0; i < 1000; ++i) { out.writeChars("Hello\n"); } out.close(); return path; }
Example 16
Source File: EquipmentScreen.java From Alite with GNU General Public License v3.0 | 5 votes |
@Override public void saveScreenState(DataOutputStream dos) throws IOException { dos.writeByte(selection == null ? 0 : selection.getName().length()); if (selection != null) { dos.writeChars(selection.getName()); } }
Example 17
Source File: DataOutputImpl.java From libsu with Apache License 2.0 | 5 votes |
@Override default void writeChars(@NonNull String s) throws IOException { ByteArrayOutputStream buf = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(buf); out.writeChars(s); write(buf.toByteArray()); }
Example 18
Source File: X509ExtensionSet.java From keystore-explorer with GNU General Public License v3.0 | 5 votes |
private void saveExtensions(Map<String, byte[]> extensions, DataOutputStream dos) throws IOException { dos.writeInt(extensions.size()); for (String oid : extensions.keySet()) { dos.writeInt(oid.length()); dos.writeChars(oid); byte[] value = extensions.get(oid); dos.writeInt(value.length); dos.write(value); } }
Example 19
Source File: OldAndroidDataInputStreamTest.java From j2objc with Apache License 2.0 | 4 votes |
public void testDataInputStream() throws Exception { String str = "AbCdEfGhIjKlM\nOpQ\rStUvWxYz"; ByteArrayInputStream aa = new ByteArrayInputStream(str.getBytes()); ByteArrayInputStream ba = new ByteArrayInputStream(str.getBytes()); ByteArrayInputStream ca = new ByteArrayInputStream(str.getBytes()); ByteArrayInputStream da = new ByteArrayInputStream(str.getBytes()); DataInputStream a = new DataInputStream(aa); try { Assert.assertEquals(str, read(a)); } finally { a.close(); } DataInputStream b = new DataInputStream(ba); try { Assert.assertEquals("AbCdEfGhIj", read(b, 10)); } finally { b.close(); } DataInputStream c = new DataInputStream(ca); try { Assert.assertEquals("bdfhjl\np\rtvxz", skipRead(c)); } finally { c.close(); } DataInputStream d = new DataInputStream(da); try { assertEquals("AbCdEfGhIjKlM", d.readLine()); assertEquals("OpQ", d.readLine()); assertEquals("StUvWxYz", d.readLine()); } finally { d.close(); } ByteArrayOutputStream e = new ByteArrayOutputStream(); DataOutputStream f = new DataOutputStream(e); try { f.writeBoolean(true); f.writeByte('a'); f.writeBytes("BCD"); f.writeChar('e'); f.writeChars("FGH"); f.writeUTF("ijklm"); f.writeDouble(1); f.writeFloat(2); f.writeInt(3); f.writeLong(4); f.writeShort(5); } finally { f.close(); } ByteArrayInputStream ga = new ByteArrayInputStream(e.toByteArray()); DataInputStream g = new DataInputStream(ga); try { assertTrue(g.readBoolean()); assertEquals('a', g.readByte()); assertEquals(2, g.skipBytes(2)); assertEquals('D', g.readByte()); assertEquals('e', g.readChar()); assertEquals('F', g.readChar()); assertEquals('G', g.readChar()); assertEquals('H', g.readChar()); assertEquals("ijklm", g.readUTF()); assertEquals(1, g.readDouble(), 0); assertEquals(2f, g.readFloat(), 0f); assertEquals(3, g.readInt()); assertEquals(4, g.readLong()); assertEquals(5, g.readShort()); } finally { g.close(); } }
Example 20
Source File: CASSerializer.java From uima-uimaj with Apache License 2.0 | 4 votes |
private void outputStringHeap( DataOutputStream dos, CASImpl cas, StringHeapDeserializationHelper shdh, BinaryCasSerDes bcsd) throws IOException { // output the strings // compute the number of total size of data in stringHeap // total size = char buffer length + length of strings in the string list; int stringHeapLength = shdh.charHeapPos; int stringListLength = 0; for (int i = 0; i < shdh.refHeap.length; i += 3) { int ref = shdh.refHeap[i + StringHeapDeserializationHelper.STRING_LIST_ADDR_OFFSET]; // this is a string in the string list // get length and add to total string heap length if (ref != 0) { // terminate each string with a null stringListLength += 1 + bcsd.stringHeap.getStringForCode(ref).length(); } } int stringTotalLength = stringHeapLength + stringListLength; if (stringHeapLength == 0 && stringListLength > 0) { // nothing from stringHeap // add 1 for the null at the beginning stringTotalLength += 1; } dos.writeInt(stringTotalLength); // write the data in the stringheap, if there is any if (stringTotalLength > 0) { if (shdh.charHeapPos > 0) { dos.writeChars(String.valueOf(shdh.charHeap, 0, shdh.charHeapPos)); } else { // no stringheap data // if there is data in the string lists, write a leading 0 if (stringListLength > 0) { dos.writeChar(0); } } // word alignment if (stringTotalLength % 2 != 0) { dos.writeChar(0); } } // write out the string ref heap // each reference consist of a offset into stringheap and a length int refheapsz = ((shdh.refHeap.length - StringHeapDeserializationHelper.FIRST_CELL_REF) / StringHeapDeserializationHelper.REF_HEAP_CELL_SIZE) * 2; refheapsz++; dos.writeInt(refheapsz); dos.writeInt(0); for (int i = StringHeapDeserializationHelper.FIRST_CELL_REF; i < shdh.refHeap.length; i += 3) { dos.writeInt(shdh.refHeap[i + StringHeapDeserializationHelper.CHAR_HEAP_POINTER_OFFSET]); dos.writeInt(shdh.refHeap[i + StringHeapDeserializationHelper.CHAR_HEAP_STRLEN_OFFSET]); } }