解析文件显示随机的字母数字文本在textView Android

parse file displays random alphanumeric text in textView Android

本文关键字:文本 数字 textView Android 文件 显示 随机      更新时间:2023-09-26

我从parse.com得到一个解析文件,这是一个字符串消息,并在textView中显示它。

ParseFile file = message.getParseFile(ParseConstants.KEY_FILE);
        String filePath = file.getDataInBackground().toString(); 
        if (messageType.equals("string")){
            Intent intent = new Intent(getActivity(), StringActivity.class);
            intent.putExtra("file", filePath);

字符串活动类我尝试在textView中显示文件:

 protected TextView mDisplay;
 mDisplay = (TextView)findViewById(R.id.stringDisplay);
 String mess = getIntent().getStringExtra("file");
 byte[] by = mess.getBytes();
 String filePath =new String(by);
 mDisplay.setText(filePath);

textView中显示的是这个bolts.Task@12af9f90随机数。

如何显示字符串?

这将为您提供文件的内容:

String fileContent = "";
try {
    fileContent = new String(file.getData());
} catch (ParseException e) {
    e.printStackTrace();
}