OverflowInRead.java 文件源码

java
阅读 20 收藏 0 点赞 0 评论 0

项目:openjdk-jdk10 作者:
public static void main(String[] args) throws Exception {
    String s = "_123456789_123456789_123456789_123456789"; // s.length() > 33
    try (StringBufferInputStream sbis = new StringBufferInputStream(s)) {
        int len1 = 33;
        byte[] buf1 = new byte[len1];
        if (sbis.read(buf1, 0, len1) != len1)
            throw new Exception("Expected to read " + len1 + " bytes");

        int len2 = Integer.MAX_VALUE - 32;
        byte[] buf2 = new byte[len2];
        int expLen2 = s.length() - len1;
        if (sbis.read(buf2, 0, len2) != expLen2)
            throw new Exception("Expected to read " + expLen2 + " bytes");
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号