Java.lang.String
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
Byte 배열로 표현된 문자열을 String으로 변환하는 방법.
참고로, Byte 배열로 표현된 정수를 int로 변환하는 방법은 다음과 같다:
// byte num[]에 값이 들어있을때
ByteBuffer bytebuf = ByteBuffer.allocate(512);
bytebuf.put(num);
int intnum = bytebuf.getInt();
숫자(Valueable)를 문자열(String)로 변환하는 방법
- 문자열을, 숫자(정수/실수)로 변환; String to Number (int float double)
-
Integer.parseInt()
: 32bit 정수형 변환. -
Long.parseLong()
: 64Bit 정수형 변환. -
Float.parseFloat()
: 32bit 실수형 변환. -
Double.parseDouble()
: 64bit 실수형 변환.