0
byte[] serObj = getBytesFromFile(file);
final byte[] CLRF = { '\r', '\n' };
Base64 encoded = new Base64 (72,CLRF);
System.out.println(encoded.encodeBase64String(serObj));
我有问题格式化输出,它目前显示为一行,而不是根据构造函数中的参数。它应该是一个有72个字符的行,然后是CLRF和下一行。有人能指出代码有什么问题吗?另外,我怎么能手动追加/添加一个字符串中的换行符?我尝试过使用char计数器,但是一旦计数器达到第72个字符,我就不得不添加\ n。将换行附加到Base64编码的字符串。
public static int count(Reader in) throws IOException {
char[] buffer = new char[4096];
int count = 0;
int len;
while((len = in.read(buffer)) != -1) {
count += len;
}
return count;
}
@ StephenC.thx.解开我好奇心的第一部分。 – reukEN11