`
蛤蟆仙人
  • 浏览: 117770 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

ignores result of java.io.InputStream.read

 
阅读更多

 ignores result of java.io.InputStream.read(byte[], int, int)

 

This method ignores the return value of one of the variants of java.io.InputStream.read() which can return multiple bytes.  If the return value is not checked, the caller will not be able to correctly handle the case where fewer bytes were read than the caller requested.  This is a particularly insidious kind of bug, because in many programs, reads from input streams usually do read the full amount of data requested, causing the program to fail only sporadically.

 

解决办法:   if (inputStream != null) {
                ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
                int ch;
                while ((ch = inputStream.read()) != -1) {
                    bytestream.write(ch);
                }
                but = bytestream.toByteArray();
                bytestream.close();
            }

分享到:
评论

相关推荐

    findbugs检测提示详解

    4. **ignores exceptional return value of java.io.File.mkdirs()**:`File.mkdirs()`方法会返回一个布尔值,表示创建目录是否成功。忽略这个返回值可能导致忽视错误。正确做法是检查返回值: ```java if (!exitDir...

    Windows读写Ext2/Ext3/Ext4文件系统4

    Secondly, the program provides for read-only access and does not allow you to make records in file system partitions. This guarantees that the interference in an alterative file system will not ...

    JAD解决MISSING_BLOCK_LABEL心得

    Currently Jad ignores the contents of the Line Number Table Attribute and the Source File Attribute(不明白什么意思) 5.JAD不能处理继承信息,总是把java.lang.Object作为两个不同类的通用父类,需要的时候...

    xmodem:适用于Python的XMODEM协议实现

    XMODEM协议实现可在获得的文档可以在上找到Python Package ... return ser.read(size) or None...>>> def putc(data, timeout=1):... return ser.write(data) # note that this ignores the timeout...>>> modem =

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    - FIX: The result rectangle incorrectly calculated in the TFlexText.GetRefreshRect method. - FIX: Added FPaintCache.rcPaint cleanup in the TFlexPanel.WMPaint method. Now it is possible to define is ...

    ANSYS Mechanical APDL Command Reference.pdf

    a star (*) or a slash (/) ignores those symbols. A printed copy of the Commands Quick Reference Guide is available on the ANSYS Customer Portal in the documentation area. The following Command ...

    Shell-config-files:Bash配置文件和其他配置

    .inputrc - Autocomplete ignores case. Search with up/down arrows. Visible bell instead of audible. .profile - Heart of things... See below. .shell_colors - Definitions for use by .profile. .toprc - ...

    三维GIS,x3dearth

    This examples translates a world...It parses the grid in the input file and ignores the other parts. It requires a pre-computed images directory, which can be generated using the SmoothImageSlicer tool.

    EurekaLog_7.5.0.0_Enterprise

    7)....Added: Streaming unpacked debug info into temporal files instead of memory - this greatly reduces run-time application memory usage at cost of slightly slower exception processing. This also ...

    windows update logic

    However, WU ignores the ranking of INF compatibleIDs. These are hardware IDs listed in the INF file as compatible with the device but not the exact hardware ID. INF compatibleIDs are ranked lower ...

    shipit-cnpm:Shipit的cnpm任务

    Shipit-cnpm Shipit的cnpm任务 支持标志 用法 var cnpm = require ( 'shipit-cnpm' ) ; var deploy = require ( 'shipit-deploy' ) ; module .... deploy ( shipit ) ;... shipit .... ignores : [ '.git' ] ,

    WPTools.v6.29.1.Pro

    - fix for wrong display of tables with header and footer rows. Sometimes both were painted without any data. + to load old Hiedit templates as RTF code use the formatstring -HiEditFields. This will ...

    Delphi7.1 Update

    including previously installed release notes.Borland recommends that you read this file in its entirety.NOTE: If you are updating a localized version of Delphi 7, visit the Borland Registered User ...

    Dundas.Chart.for.Winform.Enterprise.v7.1.0.1812.for.VS2008

    The ASP.NET Chart ignores this property by default now. Chart .NET: Stacked Column + 3D throws an Index was out of range exception when series have a different number of data points The accumulation ...

    模糊逻辑月球登录器

    The Moon lander simulator is a very simple moon landing simulator based on the LEM from Apollo 11, it works in only 2 dimensions and ignores spaceship roll/rotation. The simulation begins after the ...

    HDDamus 2.5

    HDDamus is a professional software package that allows you to analyze your hard disk drive failures, including hardware, and prevent loss of important data with the help of special tools that can fix ...

    acpi控制笔记本风扇转速

    memory, instead of performing a bytewise read. (Region must be of type SystemMemory, see below.) Fixed the Load ASL operator for the case where the source operand is a region field. A buffer object ...

    数位板压力测试

    The availability of drivers that support the features of the specification will simplify the process of developing Windows appli¬cation programs that in-corporate absolute coordinate input, and ...

    Findbugs缺陷等级对照表

    3. CRV: Method ignores return value:方法忽略了返回值,这可能会导致错误的结果。 FindBugs会检测到这种情况,并报告一个缺陷,提醒开发者检查代码中是否存在错误的结果。 4. ASI: Static initializer invokes ...

Global site tag (gtag.js) - Google Analytics