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kVxKQ4vYuIi19
bUDuUQ7GPTO8QpZtf0tSocOi7FfGI8cWbm2LyXGnLl+FUQ==
-----END CERTIFICATE-----

求高手指定下........
展开
 我来答
六尾小狐狸
2012-12-19 · TA获得超过593个赞
知道小有建树答主
回答量:624
采纳率:74%
帮助的人:378万
展开全部
我就不输入输出流了,参考下思路吧,就是加个变量作为计数器就好了。

public class test {
public static void main(String[] args) {
String str="MIIC7jCCAlegAwIBAgIUfnKSsmMcfWy5GAoQXSvRUOCqDgAwDQYJKoZIhvcNAQEFBQAwWzEZMBcGA1UECh4QWSlaAYvaT+H/CG1Li9X/CTEbMBkGA1UECx4SWSlaAYvaT+H/CG1Li9X/CZDoMSEwHwYDVQQDHhhZKVoBi9pP4f8IbUuL1f8JdShiNwBDAEEwHhcNMTIxMjE5MDAwMDAwWhcNMTMxMjE4MjM1OTU5WjBCMRMwEQYDVQQKDAppdHJ1c2NoaW5hMRkwFwYDVQQLDBBDVVAgc3VwZXIgc2VydmVyMRAwDgYDVQQDDAd4aWFvemhpMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC5msMuVhjc83sLyy40UwsSpTWBvnlrPAdwoOFJWw+lJ6IPrft5DIO9pTyq+Dc1RGbvY9yAF5nT7yNFMY01/SjOaUY0cAlSitbPAhV1ALRlM+XnbRGimnqcR1v32iiXEoPkybvLxmjdCN8uZ5eICCh9xiZjLE/IJZWGksSL6PTKyQIDAQABo4HHMIHEMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgO4MBEGCWCGSAGG+EIBAQQEAwIGQDA0BgNVHSUELTArBggrBgEFBQcDAQYIKwYBBQUHAwIGCisGAQQBgjcKAwMGCWCGSAGG+EIEATBhBgNVHR8EWjBYMFagVKBShlBodHRwOi8vMTkyLjE2OC4wLjEyNTo5MDgwL3B1YmxpYy9pdHJ1c2NybC5kbz9DQT0wMUY3QzU4NEE4NkZBNjIyRjg4RjQ0OTc3MTg0ODIwMTANBgkqhkiG9w0BAQUFAAOBgQAmFpKC4yYeSI+iNbBUAaXjlafMxJW2vWEN5Rb9E31dneqqf7H0G8/0D0HY0KQr8HQY/hYzN1nKIAB0CHxHhb13cZeFxaPb+vRw9Ee2FGzUEqS+HQybC0AQWkgsZQ8pThH9d/aN02634CSrlxtNDGdAa2UNo6Xt3z1WjnW0jAW8fg==";
int count=1; //加入一个计数器
for(int i=0;i<str.length();i++){
System.out.print(str.charAt(i));
count++;
if(count==65){ //自己定义下多少个字符换行,你样例是65个换行
System.out.println(); //到了65个字就换行,也就是写入/r/n
count=1; //计数器初始化
}
}
}
}
追问
我写了,但我怎么在指定的位置写入/r/n,再指点下吧。
追答
比如bw.write("\r\n");
bd9006
2012-12-19 · TA获得超过2.5万个赞
知道大有可为答主
回答量:4.8万
采纳率:63%
帮助的人:1.6亿
展开全部
每隔65个字符加一个 \r\n 或 只加\n(Unix)
追问
这个我知道,但我的循环怎么写?给点提示^-^
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
cly9366
2012-12-19
知道答主
回答量:28
采纳率:100%
帮助的人:14.4万
展开全部
要换行的字符尾 加上“/r/n”
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2012-12-19
展开全部
\n
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式