Android类型转换 积累
String-->InputStream
String str = "abc"; InputStream inputStream = new ByteArrayInputStream(str.getBytes());
InputStream-->String
String inputStream2String(InputStream is) { BufferedReader in = new BufferedReader(new InputStreamReader(is)); StringBuffer buffer = new StringBuffer(); String line = ""; try { while ((line = in.readLine()) != null) { buffer.append(line); } } catch (IOException e) { e.printStackTrace(); } return buffer.toString(); }
base64-->String
String result = "abc";
byte[] encodeRes = Base64.decode(result, Base64.DEFAULT);
String res = new String(encodeRes);
String-->base64
Base64.encodeToString(str.getBytes(), Base64.DEFAULT);
char[]-->jstring
jstring jstr; char str[]="Hello World/n"; jstr=env->NewStringUTF(str); return jstr;