Is it ok to remove newline in Base64 encoding(在Base64编码中删除换行符是否可以)
问题描述
我的 java 应用程序使用 base64 编码,它在每 76 个字符后放置一个新行 (
).我需要将此编码字符串放在属性文件中,换行符会破坏功能.
My java application use base64 encoding which puts a new line (
) after every 76 character. I need to put this encoded string in a properties file and the newline breaks the functionality.
当我执行 encodedString.replaceAll("
", "");
时,一切正常,但我只是想确保这是预期的,我没有引入隐藏问题.
When I do a encodedString.replaceAll("
", "");
things are working fine, but I just want to make sure that this is expected and I am not introducing a hidden issue.
推荐答案
对于许多无法处理长行的旧程序来说,必须将 base64 编码的字符串分成多行.用 Java 编写的程序通常可以处理长行,因为它们不需要自己进行内存管理.只要您的行少于 6400 万个字符,就应该没有问题.
Breaking a base64 encoded string into multiple lines has been necessary for many old programs that couldn't handle long lines. Programs written in Java can usually handle long lines since they don't need to do the memory management themselves. As long as your lines are shorter than 64 million characters there should be no problem.
而且由于您不需要换行符,因此如果可能的话,您根本不应该生成它们.
And since you don't need the newlines, you shouldn't generate them at all, if possible.
这篇关于在Base64编码中删除换行符是否可以的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在Base64编码中删除换行符是否可以


- Jersey REST 客户端:发布多部分数据 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01