java非打印字符_无法在java中打印非常大的字符串(既不在Eclipse中也不在cmd中)

我正在使用非常大的字符串,其长度范围从0到2 * 10 ^ 5.

当我尝试在控制台上打印字符串或通过System.out.println使用命令行时,没有任何显示.仅显示具有4096个字符的字符串/子字符串.而且,我没有错误.

我还尝试使用System.out.print(chararray [i])一次打印一个字符,但无济于事.

我甚至试过尝试使用下面但它没有用.

StringWriter stringWriter = new StringWriter();

BufferedWriter bufferedWriter = new BufferedWriter(stringWriter);

bufferedWriter.write(str); //does not display

StringBuilder sb = new StringBuilder(str);

System.out.println(sb); //does not display

显示在这里很重要,因为我在HackerRank上提交我的程序,由于这个问题,我的程序没有通过测试用例.

有人可以帮忙吗?

注意:我知道字符串正确存储,因为我能够使用str.length()验证它们的长度;

最佳答案

By default, Eclipse limits the amount of text in the console output

window. So if you are running a program which produces a lot of

output, the Console will only display the last n lines and you lose

the rest.

Here is a tip which will allow you to have unlimited output in the

console:

Go to Window > Preferences > Run/Debug > Console

Uncheck “Limit Console Output” (Alternatively you can increase the Console buffer size.)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值