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编码中删除换行符是否可以
基础教程推荐
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 降序排序:Java Map 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01