java - 如何在 Android 中将字节字符串转换为 Ascii 字符串
问题描述
我一直在试图找到一种简单的方法来将我从第三方软件获得的缓冲区值转换为将以 .json 格式保存的 ascii 字符串,我不想要原始的十六进制格式。有什么建议么?
这是缓冲区内容的示例:
5B 7B 22 54 65 73 74 49 6E 50 72 6F 67 72 65
73 73 22 3A 20 22 4E 6F 22 2C 20 22 41 70 70
6C 69 63 61 74 69 6F 6E 20 53 6F 66 74 77 61
72 65 20 54
我要这个:
[{"TestInProgress": "No", "Application Software T
我的代码:
// Dynamically size the buffer according to file size
Buffer buff = new Buffer(Integer.valueOf(String.valueOf(FileSize)));//5000);
// read DATASIZE from the begginig of the file
jNQfile.read(buff);
Log.i(TAG, "IN AsyncTask in after read in jNQ the path ---------------------------->:" + DirForjNQ ); // debug msg
// Still in this format Message = Buffer: [5B 7B 22 54 65 ....]
String Message = buff.toString();
该文件从服务器复制,第三方堆栈设置并处理 smb。它被复制到他们的缓冲区中。该文件已经是 .json 格式。我只想要 ASCII 字符,而不是十六进制表示。
解决方案
推荐阅读
- c# - 密码未从 C# 应用程序正确存储在 SQL Server 中
- sql - 通过 SQL 在表中进行行比较
- spring-boot - Spring Boot 2.3.0 - MongoDB 库不会自动创建索引
- python - 当我尝试添加事件时,在带有两个 sizer 的 wxgrid 中,收到此错误 - TypeError: be1() 采用 1 个位置参数,但给出了 2 个
- python - 基于重复的数据帧的转置列 - 熊猫
- java - 如何将上下文传递给android库中的Intent?
- javascript - 为什么我在 JavaScript 和 DOM 操作上的 for 循环会导致我的网站崩溃?
- python - Tensorflow 基于未知批量大小 N 构造形状张量 (N*N*K)
- java - 这个同步块中发生了什么
- java - 正则表达式 - 从 JAVA 中的字符串句子中匹配邮政编码