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N6IGMOkWLeXs0WpRA+YyC8VnUgUDaqGfkVxKQ4vYuIi19
bUDuUQ7GPTO8QpZtf0tSocOi7FfGI8cWbm2LyXGnLl+FUQ==
-----END CERTIFICATE-----
求高手指定下........ 展开
4个回答
展开全部
我就不输入输出流了,参考下思路吧,就是加个变量作为计数器就好了。
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; //计数器初始化
}
}
}
}
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");
展开全部
每隔65个字符加一个 \r\n 或 只加\n(Unix)
追问
这个我知道,但我的循环怎么写?给点提示^-^
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
要换行的字符尾 加上“/r/n”
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-12-19
展开全部
\n
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询