java - 用Java读取后二进制文件的大小变化
问题描述
我的应用程序工作区上有一个大小为 512 字节的 jceks(密钥库文件)。我有下面的 java 代码,它读取这个二进制 jceks 文件并使用 Feign Client 将其推送到 Bitbucket。当文件被推送到 Bitbucket 时,大小变为 696 字节(使用 UTF-8 编码,甚至在下面的第 3 步中没有编码)。当我尝试在下面的步骤 3 中使用其他编码(如 UTF-16、UTF-16LE、UTF-BE、US-ASCII、ISO-8859_1)时,根据编码,推送文件的大小变为 707 字节、721 字节等. 有人可以让我知道如何解决这个问题吗?
//Imports
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
//Steps
1.File f = new File(//Path of jceks file on my application workspace);
2.byte[] encoded = Files.readAllBytes(Paths.get(f.getPath));
3.String toSave = new String(encoded, StandardCharsets.UTF-8);
//This String 'toSave' is what i pass to Bitbucket API which pushes the jceks file to Bitbucket, but the size in different from actual jceks file.
解决方案
推荐阅读
- javascript - Java Script + Node.js 计算器问题
- java - 创建 AmazonSNS 的 Bean 时出现异常
- javascript - 提取django多选表单选择
- mysql - 如何使用asp classic将emoij插入mysql数据库?
- c# - Modelstate errors not shown correctly
- rust - 为什么我得到带有向量向量的“没有为类型 Option 找到名为 push 的方法”?
- c++ - Qt3D Project does not show any result after succesful compiling
- php - 首先执行什么?它是php标签内的脚本还是HTML?
- python - using melt function in groupby for large data sets in python
- java - 在单独的线程中定义的绘制函数而不是绘图(Java)