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

📄 jmoutputstream.java.svn-base

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

import java.io.* ;

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

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

    private DataOutputStream poStream ;
    private ByteArrayOutputStream poOut ;

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

    /**
     * 僐儞僗僩儔僋僞
     */
    public JMOutputStream ()
    {
        this ( 256 ) ;
    }

    /**
     * 弶婜僶僢僼傽僒僀僘傪巜掕偡傞応崌偺僐儞僗僩儔僋僞
     * @param  aiSize		僒僀僘弶婜抣乮僶僀僩悢乯
     */
    public JMOutputStream ( int aiSize )
    {
        poOut = new ByteArrayOutputStream ( aiSize ) ;
        poStream = new DataOutputStream ( poOut ) ;
    }

    /**
     * 弌椡僗僩儕乕儉傪僼儔僢僔儏偡傞丅
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public void flush ()
        throws IOException
    {
        poStream.flush () ;
    }

    /**
     * 弌椡僗僩儕乕儉傪暵偠傞丅
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public void close ()
        throws IOException
    {
        poStream.close () ;
    }

    /**
     * 弌椡僗僩儕乕儉偵彂偒崬傑傟偨僶僀僩悢傪曉偡丅
     * @return 僗僩儕乕儉偵彂偒崬傑傟偨僶僀僩悢
     */
    public final int size ()
    {
        return poStream.size () ;
    }

    /**
     * <tt>ByteArrayOutputStream</tt>傪曉偡丅<BR>
     * @return 弌椡僗僩儕乕儉
     */
    public final ByteArrayOutputStream getOutputStream ()
    {
        return poOut ;
    }

    /**
     * 弌椡僗僩儕乕儉偺撪梕傪僶僀僩攝楍偵彂偒弌偡丅
     * @return 僶僀僩攝楍
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final byte[] toByteArray ()
        throws IOException
    {
        flush () ;
        return poOut.toByteArray () ;
    }

    /**
     * byte 幆暿巕傪彂偒崬傫偩屻偵 byte 抣傪彂偒崬傓丅
     * @param  aiValue		彂偒崬傓 byte 抣
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeByte ( int aiValue )
        throws IOException
    {
        poStream.writeByte ( PREFIX_OF_BYTE ) ;
        poStream.writeByte ( aiValue ) ;
//        ObjectOutputStream aa = new ObjectOutputStream(poStream);
//        aa.writeObject("");
//        aa.writeObject(m);
    }

    /**
     * short 幆暿巕傪彂偒崬傫偩屻偵 short 抣傪彂偒崬傓丅
     * @param  aiValue		彂偒崬傓 short 抣
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeShort ( int aiValue )
        throws IOException
    {
        poStream.writeByte ( PREFIX_OF_SHORT ) ;
        poStream.writeShort ( aiValue ) ;
    }

    /**
     * int 幆暿巕傪彂偒崬傫偩屻偵 int 抣傪彂偒崬傓丅
     * @param  aiValue		彂偒崬傓 int 抣
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeInt ( int aiValue )
        throws IOException
    {
        poStream.writeByte ( PREFIX_OF_INT ) ;
        poStream.writeInt ( aiValue ) ;
    }

    /**
     * long 幆暿巕傪彂偒崬傫偩屻偵 long 抣傪彂偒崬傓丅
     * @param  alValue		彂偒崬傓 long 抣
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeLong ( long alValue )
        throws IOException
    {
        poStream.writeByte ( PREFIX_OF_LONG ) ;
        poStream.writeLong ( alValue ) ;
    }

    /**
     * float 幆暿巕傪彂偒崬傫偩屻偵 float 抣傪彂偒崬傓丅
     * @param  afValue		彂偒崬傓 float 抣
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeFloat ( float afValue )
        throws IOException
    {
        poStream.writeByte ( PREFIX_OF_FLOAT ) ;
        poStream.writeFloat ( afValue ) ;
    }

    /**
     * double 幆暿巕傪彂偒崬傫偩屻偵 double 抣傪彂偒崬傓丅
     * @param  adValue		彂偒崬傓 double 抣
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeDouble ( double adValue )
        throws IOException
    {
        poStream.writeByte ( PREFIX_OF_DOUBLE ) ;
        poStream.writeDouble ( adValue ) ;
    }

    /**
     * char 幆暿巕傪彂偒崬傫偩屻偵 char 抣傪彂偒崬傓丅
     * @param  aiValue		彂偒崬傓 char 抣
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeChar ( int aiValue )
        throws IOException
    {
        poStream.writeByte ( PREFIX_OF_CHAR ) ;
        poStream.writeChar ( aiValue ) ;
    }

    /**
     * boolean 幆暿巕傪彂偒崬傫偩屻偵 boolean 抣傪彂偒崬傓丅
     * @param  abValue		彂偒崬傓 boolean 抣
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeBoolean ( boolean abValue )
        throws IOException
    {
        poStream.writeByte ( PREFIX_OF_BOOLEAN ) ;
        poStream.writeBoolean ( abValue ) ;
    }

    /**
     * UTF 幆暿巕傪彂偒崬傫偩屻偵暥帤楍傪倀俿俥亅俉晞崋壔宍幃傪彂偒崬傓丅
     * @param  asValue		彂偒崬傓暥帤楍
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeUTF ( String asValue )
        throws IOException
    {
        poStream.writeByte ( PREFIX_OF_UTF ) ;
        poStream.writeUTF ( asValue ) ;
    }

    /**
     * 攝楍挿幆暿巕傪彂偒崬傫偩屻偵攝楍挿傪帵偡 int 抣傪彂偒崬傓丅
     * @param  asValue		彂偒崬傓暥帤楍
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeArrayLength ( int aiValue )
        throws IOException
    {
        poStream.writeByte ( PREFIX_OF_ARRAY ) ;
        poStream.writeInt ( aiValue ) ;
    }

    /**
     * 僆僽僕僃僋僩幆暿巕傪彂偒崬傫偩屻偵丄僋儔僗柤暥帤楍傪彂偒崬傓丅
     * @param  asValue		彂偒崬傓僋儔僗柤暥帤楍
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeClassName ( String asValue )
        throws IOException
    {
        poStream.writeByte ( PREFIX_OF_OBJECT ) ;
        poStream.writeUTF ( asValue ) ;
    }

    /**
     * 慜抲僐乕僪傪彂偒崬傓丅
     * @param  ayPrefix		彂偒崬傓慜抲僐乕僪
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writePrefix ( byte ayPrefix )
        throws IOException
    {
        poStream.writeByte ( ayPrefix ) ;
    }

    /**
     * int 抣偩偗傪彂偒崬傓丅
     * @param  aiValue		彂偒崬傓 int 抣
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeRawInt ( int aiValue )
        throws IOException
    {
        poStream.writeInt ( aiValue ) ;
    }

    /**
     * long 抣偩偗傪彂偒崬傓丅
     * @param  alValue		彂偒崬傓 long 抣
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeRawLong ( long alValue )
        throws IOException
    {
        poStream.writeLong ( alValue ) ;
    }

    /**
     * UTF 抣偩偗傪彂偒崬傓丅
     * @param  asValue		彂偒崬傓 String 抣
     * @throws IOException		擖弌椡僄儔乕偑敪惗偟偨応崌
     */
    public final void writeRawUTF ( String asValue )
        throws IOException
    {
        poStream.writeUTF ( asValue ) ;
    }

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

⌨️ 快捷键说明

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