http://expert.csdn.net/Expert/topic/1403/1403714.xml?temp=.3927881

解决方案 »

  1.   

    比你的RAM要大
    不过要注意性能,不要用String做拼接操作
      

  2.   

    可以查一下 String 和 StringBuffer 获得长度的方法public int length()
    Returns the length of this string. The length is equal to the number of 16-bit Unicode characters in the string.获得 String 和 StringBuffer 的长度的方法都是 int length()
    下面就可以计算出他们的最大长度了
    int 是一个 32 位变量类型 取正数部分来算的话 他们最长可以有 2^31-1 = 2147483647 个 16-bit Unicode character 共 2147483647 * 16 = 34359738352 位
    34359738352 / 8 = 4294967294 (Byte)
    4294967294 / 1024 = 4194303.998046875 (KB)
    4194303.998046875 / 1024 = 4095.9999980926513671875 (MB)
    4095.9999980926513671875 / 1024 = 3.99999999813735485076904296875 (GB)有近 4G 的容量