`
蛤蟆仙人
  • 浏览: 114920 次
  • 性别: 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(); 5、invokes inefficient new Short(short) constructor; use Short.valueOf(short) instead; ………… 总共总结常见的22条,供大家参考

    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 ...

    论文 多任务学习

    However, feature selection, which is one of the most important steps in classification, is typically performed separately for each modality, which ignores the potentially strong inter-modality ...

    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 ...

    shipit-cnpm:Shipit的cnpm任务

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

    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 ...

    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 ...

    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 ...

    Curiosity-driven Exploration by Self-supervised Prediction.pdf

    pixels, and, critically, ignores the aspects of the environment that cannot affect the agent. The proposed approach is evaluated in two environments: VizDoom and Super Mario Bros. Three broad ...

    PLSQL.Developer v11.0.4.1774 主程序+ v11中文包+keygen

    Compare Table Data tool now ignores virtual columns You can now use comma's in substitution variable lists and checkboxes by specifying 2 comma's: &(-20000,, '[#]'), null"> Substitution variable ...

Global site tag (gtag.js) - Google Analytics