简体   繁体   English

如何在Android中将二进制字符串数据转换为字符串

[英]how to convert binary string data into String in android

Can anybody give me some clue that how to convert binary string into a string(english). 任何人都可以给我一些线索,如何将二进制字符串转换为字符串(英语)。 I have tried and googled so much but couldn't find an answer. 我已经尝试和搜索了很多,但是找不到答案。

Here is my code: 这是我的代码:

InputStream iStream = getApplicationContext().getResources().openRawResource(R.raw.map);
InputStreamReader input;
String line = "";
//char character[] = null;
//String res = "";
input = new InputStreamReader(iStream); 
BufferedReader bf = new BufferedReader(input);

Log.i("Helloo i am above variable", "Variable");

try {
    line = bf.readLine();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
Log.i("hello helloo", line.toString());

Thanks in advance. 提前致谢。

Have you tried the constructor InputStreamReader(InputStream in, Charset charset) with Charset.forName("UTF-8") as Charset ? 您是否尝试过使用Charset.forName("UTF-8")作为Charset的构造函数InputStreamReader(InputStream in, Charset charset) However, if you try representing data which is other than a string, this won't give you any, except maybe something ugly or an error... 但是,如果您尝试表示字符串以外的数据,则不会给您任何信息,除非可能是丑陋的错误或错误...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM