⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jminputstream.java.svn-base

📁 MSN客服自动化机器人
💻 SVN-BASE
字号:
package jm.util ;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;

/**
 * <tt>JMFolder使用的流工具</tt>
 * @author fu_changyong(1shome)
 * @see jdk1.5.2
 * @version 1.5.2.2
 */
public class JMInputStream
    implements JMStreamPrefix
{
//    private final String CLASS_NAME = "JMInputStream" ;

    //////////////////////////////////////////////////////////////////////////
    // 僼傿乕儖僪愰尵

    private DataInputStream poStream ;

    //////////////////////////////////////////////////////////////////////////
    // 僐儞僗僩儔僋僞

    /**
     * 僶僀僩攝楍傪巜掕偟偰擖椡僗僩儕乕儉傪嶌惉偡傞丅
     * @param  ayBuf			僶僀僩僨乕僞攝楍
     */
    public JMInputStream ( byte[] ayBuf )
    {
        ByteArrayInputStream oIn = new ByteArrayInputStream ( ayBuf ) ;
        poStream = new DataInputStream ( oIn ) ;
    }

    /**
     * 擖椡僗僩儕乕儉傪巜掕偟偰擖椡僗僩儕乕儉傪嶌惉偡傞丅
     * @param  aoStream		擖椡僗僩儕乕儉
     */
    public JMInputStream ( InputStream aoStream )
    {
        poStream = new DataInputStream ( aoStream ) ;
    }

    //////////////////////////////////////////////////////////////////////////
    // public 儊僜僢僪

    /**
     * 擖椡僗僩儕乕儉傪暵偠傞丅
     * @throws	IOException
     */
    public void close ()
        throws IOException
    {
        poStream.close () ;
    }

    /**
     * byte 幆暿巕傪妋擣偟偨屻丄byte 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 byte 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     * @throws IllegalArgumentException	擖椡僗僩儕乕儉偺撪梕偑晄惓偺応崌
     */
    public final byte readByte ()
        throws EOFException , IOException , IllegalArgumentException
    {
        byte yPrefix = poStream.readByte () ;
        if ( yPrefix != PREFIX_OF_BYTE )
        {
            String sDesc = "byte幆暿巕[" + yPrefix + "]偑晄惓偱偡" ;
            throw new IllegalArgumentException ( sDesc ) ;
        }
        return poStream.readByte () ;
    }

    /**
     * short 幆暿巕傪妋擣偟偨屻丄short 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 short 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     * @throws IllegalArgumentException	擖椡僗僩儕乕儉偺撪梕偑晄惓偺応崌
     */
    public final short readShort ()
        throws EOFException , IOException , IllegalArgumentException
    {
        byte yPrefix = poStream.readByte () ;
        if ( yPrefix != PREFIX_OF_SHORT )
        {
            String sDesc = "short幆暿巕[" + yPrefix + "]偑晄惓偱偡" ;
            throw new IllegalArgumentException ( sDesc ) ;
        }
        return poStream.readShort () ;
    }

    /**
     * int 幆暿巕傪妋擣偟偨屻丄int 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 int 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     * @throws IllegalArgumentException	擖椡僗僩儕乕儉偺撪梕偑晄惓偺応崌
     */
    public final int readInt ()
        throws EOFException , IOException , IllegalArgumentException
    {
        byte yPrefix = poStream.readByte () ;
        if ( yPrefix != PREFIX_OF_INT )
        {
            String sDesc = "int幆暿巕[" + yPrefix + "]偑晄惓偱偡" ;
            throw new IllegalArgumentException ( sDesc ) ;
        }
        return poStream.readInt () ;
    }

    /**
     * long 幆暿巕傪妋擣偟偨屻丄long 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 long 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     * @throws IllegalArgumentException	擖椡僗僩儕乕儉偺撪梕偑晄惓偺応崌
     */
    public final long readLong ()
        throws EOFException , IOException , IllegalArgumentException
    {
        byte yPrefix = poStream.readByte () ;
        if ( yPrefix != PREFIX_OF_LONG )
        {
            String sDesc = "long幆暿巕[" + yPrefix + "]偑晄惓偱偡" ;
            throw new IllegalArgumentException ( sDesc ) ;
        }
        return poStream.readLong () ;
    }

    /**
     * float 幆暿巕傪妋擣偟偨屻丄float 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 float 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     * @throws IllegalArgumentException	擖椡僗僩儕乕儉偺撪梕偑晄惓偺応崌
     */
    public final float readFloat ()
        throws EOFException , IOException , IllegalArgumentException
    {
        byte yPrefix = poStream.readByte () ;
        if ( yPrefix != PREFIX_OF_FLOAT )
        {
            String sDesc = "float幆暿巕[" + yPrefix + "]偑晄惓偱偡" ;
            throw new IllegalArgumentException ( sDesc ) ;
        }
        return poStream.readFloat () ;
    }

    /**
     * double 幆暿巕傪妋擣偟偨屻丄double 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 double 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     * @throws IllegalArgumentException	擖椡僗僩儕乕儉偺撪梕偑晄惓偺応崌
     */
    public final double readDouble ()
        throws EOFException , IOException , IllegalArgumentException
    {
        byte yPrefix = poStream.readByte () ;
        if ( yPrefix != PREFIX_OF_DOUBLE )
        {
            String sDesc = "double幆暿巕[" + yPrefix + "]偑晄惓偱偡" ;
            throw new IllegalArgumentException ( sDesc ) ;
        }
        return poStream.readDouble () ;
    }

    /**
     * char 幆暿巕傪妋擣偟偨屻丄char 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 char 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     * @throws IllegalArgumentException	擖椡僗僩儕乕儉偺撪梕偑晄惓偺応崌
     */
    public final char readChar ()
        throws EOFException , IOException , IllegalArgumentException
    {
        byte yPrefix = poStream.readByte () ;
        if ( yPrefix != PREFIX_OF_CHAR )
        {
            String sDesc = "char幆暿巕[" + yPrefix + "]偑晄惓偱偡" ;
            throw new IllegalArgumentException ( sDesc ) ;
        }
        return poStream.readChar () ;
    }

    /**
     * boolean 幆暿巕傪妋擣偟偨屻丄boolean 抣傪撉傒崬傓丅
     * @return 撉傒崬傑傟偨 boolean 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     * @throws IllegalArgumentException	擖椡僗僩儕乕儉偺撪梕偑晄惓偺応崌
     */
    public final boolean readBoolean ()
        throws EOFException , IOException , IllegalArgumentException
    {
        byte yPrefix = poStream.readByte () ;
        if ( yPrefix != PREFIX_OF_BOOLEAN )
        {
            String sDesc = "boolean幆暿巕[" + yPrefix + "]偑晄惓偱偡" ;
            throw new IllegalArgumentException ( sDesc ) ;
        }
        return poStream.readBoolean () ;
    }

    /**
     * UTF 幆暿巕傪妋擣偟偨屻丄暥帤楍傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨暥帤楍
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     * @throws IllegalArgumentException	擖椡僗僩儕乕儉偺撪梕偑晄惓偺応崌
     */
    public final String readUTF ()
        throws EOFException , IOException , IllegalArgumentException
    {
        byte yPrefix = poStream.readByte () ;
        if ( yPrefix != PREFIX_OF_UTF )
        {
            String sDesc = "UTF幆暿巕[" + yPrefix + "]偑晄惓偱偡" ;
            throw new IllegalArgumentException ( sDesc ) ;
        }
        return poStream.readUTF () ;
    }

    /**
     * 攝楍挿幆暿巕傪妋擣偟偨屻丄int 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨攝楍挿
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     * @throws IllegalArgumentException	擖椡僗僩儕乕儉偺撪梕偑晄惓偺応崌
     */
    public final int readArrayLength ()
        throws EOFException , IOException , IllegalArgumentException
    {
        byte yPrefix = poStream.readByte () ;
        if ( yPrefix != PREFIX_OF_ARRAY )
        {
            String sDesc = "攝楍挿幆暿巕[" + yPrefix + "]偑晄惓偱偡" ;
            throw new IllegalArgumentException ( sDesc ) ;
        }
        return poStream.readInt () ;
    }

    /**
     * 僆僽僕僃僋僩幆暿巕傪妋擣偟偨屻丄僋儔僗柤傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨僋儔僗柤
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     * @throws IllegalArgumentException	擖椡僗僩儕乕儉偺撪梕偑晄惓偺応崌
     */
    public final String readClassName ()
        throws EOFException , IOException , IllegalArgumentException
    {
        byte yPrefix = poStream.readByte () ;
        if ( yPrefix != PREFIX_OF_OBJECT )
        {
            String sDesc = "僆僽僕僃僋僩幆暿巕[" + yPrefix + "]偑晄惓偱偡" ;
            throw new IllegalArgumentException ( sDesc ) ;
        }
        return poStream.readUTF () ;
    }

    /**
     * 慜抲僐乕僪傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨慜抲僐乕僪
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     *
     */
    public final byte readPrefix ()
        throws EOFException , IOException
    {
        return poStream.readByte () ;
    }

    /**
     * 幆暿巕偺妋擣傪峴傢偢偵 byte 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 byte 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final byte readRawByte ()
        throws EOFException , IOException
    {
        return poStream.readByte () ;
    }

    /**
     * 幆暿巕偺妋擣傪峴傢偢偵 short 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 short 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final short readRawShort ()
        throws EOFException , IOException
    {
        return poStream.readShort () ;
    }

    /**
     * 幆暿巕偺妋擣傪峴傢偢偵 int 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 int 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final int readRawInt ()
        throws EOFException , IOException
    {
        return poStream.readInt () ;
    }

    /**
     * 幆暿巕偺妋擣傪峴傢偢偵 long 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 long 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final long readRawLong ()
        throws EOFException , IOException
    {
        return poStream.readLong () ;
    }

    /**
     * 幆暿巕偺妋擣傪峴傢偢偵 float 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 float 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final float readRawFloat ()
        throws EOFException , IOException
    {
        return poStream.readFloat () ;
    }

    /**
     * 幆暿巕偺妋擣傪峴傢偢偵 double 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 double 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final double readRawDouble ()
        throws EOFException , IOException
    {
        return poStream.readDouble () ;
    }

    /**
     * 幆暿巕偺妋擣傪峴傢偢偵 char 抣傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨 char 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final char readRawChar ()
        throws EOFException , IOException
    {
        return poStream.readChar () ;
    }

    /**
     * 幆暿巕偺妋擣傪峴傢偢偵 boolean 抣傪撉傒崬傓丅
     * @return 撉傒崬傑傟偨 boolean 抣
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final boolean readRawBoolean ()
        throws EOFException , IOException
    {
        return poStream.readBoolean () ;
    }

    /**
     * 幆暿巕偺妋擣傪峴傢偢偵 暥帤楍傪撉傒崬傓丅
     * @return	撉傒崬傑傟偨暥帤楍
     * @throws EOFException		僨乕僞撉傒崬傒拞偵廔抂偵払偟偨応崌
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final String readRawUTF ()
        throws EOFException , IOException
    {
        return poStream.readUTF () ;
    }

    /**
     * 擖椡僗僩儕乕儉偐傜巜掕偝傟偨僶僀僩攝楍偵僨乕僞傪撉傒崬傓丅
     * @param  yBuf			擖椡僶僢僼傽偺僶僀僩攝楍
     * @param  iOffset		擖椡僶僢僼傽偺撉傒崬傒愭摢埵抲乮0 乣乯
     * @param  iLength		嵟戝撉傒崬傒僶僀僩悢
     * @return 幚嵺偵撉傒崬傑傟偨僶僀僩悢
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final int read ( byte[] yBuf , int iOffset , int iLength )
        throws IOException
    {
        return poStream.read ( yBuf , iOffset , iLength ) ;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -