/** * Returns an array containing the <i>modified UTF-8</i> form of {@code s}, using a * big-endian 16-bit length. Throws UTFDataFormatException if {@code s} is too long * for a two-byte length. */ public static byte[] encode(String s) throws UTFDataFormatException { int utfCount = (int) ModifiedUtf8.countBytes(s, true); byte[] result = new byte[SizeOf.SHORT + utfCount]; Memory.pokeShort(result, 0, (short) utfCount, ByteOrder.BIG_ENDIAN); ModifiedUtf8.encode(result, SizeOf.SHORT, s); return result; }
private static String decodeUTF(int utfSize, DataInput in) throws IOException { byte[] buf = new byte[utfSize]; in.readFully(buf, 0, utfSize); return ModifiedUtf8.decode(buf, new char[utfSize], 0, utfSize); }
public final void writeUTF(String str) throws IOException { write(ModifiedUtf8.encode(str)); } }
/** * Writes a string encoded with {@link DataInput modified UTF-8} to this * file, starting at the current file pointer. * * @param str * the string to write in {@link DataInput modified UTF-8} * format. * @throws IOException * if an I/O error occurs while writing to this file. * @throws UTFDataFormatException * if the encoded string is longer than 65535 bytes. * @see #readUTF() */ public final void writeUTF(String str) throws IOException { write(ModifiedUtf8.encode(str)); } }
long count = ModifiedUtf8.countBytes(object, false); byte[] buffer; int offset = 0; offset += SizeOf.LONG; ModifiedUtf8.encode(buffer, offset, object); output.write(buffer, 0, buffer.length);
/** * Reads a string that is encoded in {@link DataInput modified UTF-8} from * this file. The number of bytes that must be read for the complete string * is determined by the first two bytes read from the file. Blocks until all * required bytes have been read, the end of the file is reached or an * exception is thrown. * * @return the next string encoded in {@link DataInput modified UTF-8} from * this file. * @throws EOFException * if the end of this file is detected. * @throws IOException * if this file is closed or another I/O error occurs. * @throws UTFDataFormatException * if the bytes read cannot be decoded into a character string. * @see #writeUTF(String) */ public final String readUTF() throws IOException { int utfSize = readUnsignedShort(); if (utfSize == 0) { return ""; } byte[] buf = new byte[utfSize]; if (read(buf, 0, buf.length) != buf.length) { throw new EOFException(); } return ModifiedUtf8.decode(buf, new char[utfSize], 0, utfSize); }
public final void writeUTF(String str) throws IOException { write(ModifiedUtf8.encode(str)); } }
/** * Returns an array containing the <i>modified UTF-8</i> form of {@code s}, using a * big-endian 16-bit length. Throws UTFDataFormatException if {@code s} is too long * for a two-byte length. */ public static byte[] encode(String s) throws UTFDataFormatException { int utfCount = (int) ModifiedUtf8.countBytes(s, true); byte[] result = new byte[SizeOf.SHORT + utfCount]; Memory.pokeShort(result, 0, (short) utfCount, ByteOrder.BIG_ENDIAN); ModifiedUtf8.encode(result, SizeOf.SHORT, s); return result; }
currentEntry = createZipEntry(ModifiedUtf8.decode(nameBuf, charBuf, 0, nameLength)); currentEntry.time = ceLastModifiedTime; currentEntry.modDate = ceLastModifiedDate;
public final void writeUTF(String str) throws IOException { write(ModifiedUtf8.encode(str)); } }
/** * Returns an array containing the <i>modified UTF-8</i> form of {@code s}, using a * big-endian 16-bit length. Throws UTFDataFormatException if {@code s} is too long * for a two-byte length. */ public static byte[] encode(String s) throws UTFDataFormatException { int utfCount = (int) ModifiedUtf8.countBytes(s, true); byte[] result = new byte[SizeOf.SHORT + utfCount]; Memory.pokeShort(result, 0, (short) utfCount, ByteOrder.BIG_ENDIAN); ModifiedUtf8.encode(result, SizeOf.SHORT, s); return result; }
private static String decodeUTF(int utfSize, DataInput in) throws IOException { byte[] buf = new byte[utfSize]; in.readFully(buf, 0, utfSize); return ModifiedUtf8.decode(buf, new char[utfSize], 0, utfSize); }
public final void writeUTF(String str) throws IOException { write(ModifiedUtf8.encode(str)); } }
/** * Returns an array containing the <i>modified UTF-8</i> form of {@code s}, using a * big-endian 16-bit length. Throws UTFDataFormatException if {@code s} is too long * for a two-byte length. */ public static byte[] encode(String s) throws UTFDataFormatException { int utfCount = (int) ModifiedUtf8.countBytes(s, true); byte[] result = new byte[SizeOf.SHORT + utfCount]; Memory.pokeShort(result, 0, (short) utfCount, ByteOrder.BIG_ENDIAN); ModifiedUtf8.encode(result, SizeOf.SHORT, s); return result; }
private static String decodeUTF(int utfSize, DataInput in) throws IOException { byte[] buf = new byte[utfSize]; in.readFully(buf, 0, utfSize); return ModifiedUtf8.decode(buf, new char[utfSize], 0, utfSize); }
public final void writeUTF(String str) throws IOException { write(ModifiedUtf8.encode(str)); } }
/** * Returns an array containing the <i>modified UTF-8</i> form of {@code s}, using a * big-endian 16-bit length. Throws UTFDataFormatException if {@code s} is too long * for a two-byte length. */ public static byte[] encode(String s) throws UTFDataFormatException { int utfCount = (int) ModifiedUtf8.countBytes(s, true); byte[] result = new byte[SizeOf.SHORT + utfCount]; Memory.pokeShort(result, 0, (short) utfCount, ByteOrder.BIG_ENDIAN); ModifiedUtf8.encode(result, SizeOf.SHORT, s); return result; }
private static String decodeUTF(int utfSize, DataInput in) throws IOException { byte[] buf = new byte[utfSize]; in.readFully(buf, 0, utfSize); return ModifiedUtf8.decode(buf, new char[utfSize], 0, utfSize); }
public final void writeUTF(String str) throws IOException { write(ModifiedUtf8.encode(str)); } }
/** * Returns an array containing the <i>modified UTF-8</i> form of {@code s}, using a * big-endian 16-bit length. Throws UTFDataFormatException if {@code s} is too long * for a two-byte length. */ public static byte[] encode(String s) throws UTFDataFormatException { int utfCount = (int) ModifiedUtf8.countBytes(s, true); byte[] result = new byte[SizeOf.SHORT + utfCount]; Memory.pokeShort(result, 0, (short) utfCount, ByteOrder.BIG_ENDIAN); ModifiedUtf8.encode(result, SizeOf.SHORT, s); return result; }