Java.lang.String
lastmod 2020-09-09created 2014-06-065 edits
inputStream to String
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = inputStream.read(b)) != -1;) {
out.append(new String(b, 0, n));
}
out.toString();
String to inputStream
Byte Array to String
How to convert a string represented as a Byte array to a String.
For reference, an integer represented as a Byte array can be converted to an int as follows:
// byte num[]에 값이 들어있을때
ByteBuffer bytebuf = ByteBuffer.allocate(512);
bytebuf.put(num);
int intnum = bytebuf.getInt();
How to convert a number (Valueable) to a string (String)
- Converting a string to a number (integer/floating-point); String to Number (int float double)
-
Integer.parseInt(): converts to a 32bit integer type. -
Long.parseLong(): converts to a 64Bit integer type. -
Float.parseFloat(): converts to a 32bit floating-point type. -
Double.parseDouble(): converts to a 64bit floating-point type.