Java Code Examples for java.io.DataOutputStream#writeChars()
The following examples show how to use
java.io.DataOutputStream#writeChars() .
These examples are extracted from open source projects.
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 Project: jdk8u60 File: FontConfiguration.java License: 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 Project: openjdk-jdk8u File: FontConfiguration.java License: 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 Project: Alite File: QuantityPadScreen.java License: 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 4
Source Project: Alite File: LibraryPageScreen.java License: 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 5
Source Project: hottub File: FontConfiguration.java License: 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 Project: jdk8u_jdk File: FontConfiguration.java License: 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 Project: Azzet File: JsonWriter.java License: 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 8
Source Project: jdk8u-jdk File: FontConfiguration.java License: 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 9
Source Project: Alite File: InventoryScreen.java License: 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 10
Source Project: keystore-explorer File: X509ExtensionSet.java License: 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 11
Source Project: libsu File: DataOutputImpl.java License: 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 12
Source Project: Alite File: EquipmentScreen.java License: 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 13
Source Project: RDFS File: TestDelegatingInputFormat.java License: 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 14
Source Project: hadoop-gpu File: TestDelegatingInputFormat.java License: 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 Project: hadoop File: TestDelegatingInputFormat.java License: 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 Project: hadoop File: TestMRCJCFileInputFormat.java License: 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 17
Source Project: big-c File: TestDelegatingInputFormat.java License: 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 18
Source Project: Open-Realms-of-Stars File: IOUtilities.java License: 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 19
Source Project: uima-uimaj File: CASSerializer.java License: 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]); } }
Example 20
Source Project: j2objc File: OldAndroidDataInputStreamTest.java License: 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(); } }