在Base64编码中删除换行符是否可以 [英] Is it ok to remove newline in Base64 encoding

查看:50
本文介绍了在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编码中删除换行符是否可以的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆