Java Code Examples for java.lang.String#getBytes()
The following examples show how to use
java.lang.String#getBytes() .
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: AmfString.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 5 votes |
public static void writeStringTo(OutputStream out, String string, boolean isKey) throws IOException { // Strings are ASCII encoded byte[] byteValue = string.getBytes("ASCII"); // Write the STRING data type definition (except if this String is used as a key) if (!isKey) { out.write(AmfType.STRING.getValue()); } // Write 2 bytes indicating string length Util.writeUnsignedInt16(out, byteValue.length); // Write string out.write(byteValue); }
Example 2
Source File: AmfString.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 5 votes |
/** @return the byte size of the resulting AMF string of the specified value */ public static int sizeOf(String string, boolean isKey) { try { int size = (isKey ? 0 : 1) + 2 + string.getBytes("ASCII").length; return size; } catch (UnsupportedEncodingException ex) { Log.e(TAG, "AmfString.SizeOf(): caught exception", ex); throw new RuntimeException(ex); } }