Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2026134
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类: Java

2010-09-10 17:50:06

  1. Package
    The package for IO and FS operation is java.io.
  2. Access File System
    • File
      Use the class File to access file system, such as rename, delete, listFile, etc.
    • xxx
  3. Input
    Get input from any source of data that can send out a sequence of bytes, such as file, network, memory etc.
    • InputStream
    • FileInputStream
    • StringInputStream
      Read data from a string object.
    • DataInputStream
      Read the specified length of data,
      Read boolean, long, float, int, short, byte, UTF, xxx
      Read a line,
    • RandomAccessFile
      Allows reading from and writing to a file in a random-access manner. If the file is opened in read/write mode, write operations are available as well. The position of the next read or write operation can be moved forwards and backwards after every operation.
  4. Output
    Send output to any destination that can receive a sequence of bytes.
    • OutputStream
    • FileOutputStream
    • StringOutputStream
      Write data to a string object.
    • DataOutputStream
      Write the specified length of data,
      Write boolean, long, float, int, short, byte, UTF, xxx
  5. ParcelFileDescriptor & AssetFileDescriptor
    • ParcelFileDescriptor
      ParcelFileDescriptor is created from File/Socket object, and it implements Parcel that can be transfered between different components/applications
    • AssetFileDescriptor
      Create FileInputStream/FileOutputStream object with ParcelFileDescriptor object,
    • xxx
  6. I/O Diagram


    Another diagram






  7. File System



  8. Serialization
    串行化(Serialization):把对象的表示转换成字节流的表示。
    反串行化(Deserialization):从字节流中把对象的重建出来。

    自定义串行化、反串行化类:
    实现Serializable中的方法:
    private void writeObject(java.io.ObjectOutputStream out) throws IOException
    private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException


    public final class SavingsAccount implements Serializable
    {
        private long mId;
        private name = mName;   
        private mX, mY, mW, mH;
       
        ObjectStreamField[] mFields =
        {
        new ObjectStreamField(“x”, Double.TYPE),
            new ObjectStreamField(“y”, Double.TYPE),
            new ObjectStreamField(“w”, Double.TYPE),
            new ObjectStreamField(“h”, Double.TYPE),
        };

        private void readObject( ObjectInputStream aInputStream) throws ClassNotFoundException, IOException
        {
            mId = aInputStream.readLong();
        mName = aInputStream.readUTF();

            ObjectInputStream.GetField fields = aInputStream.readFields();
            mX = fields.get(“x”, 0.0);
            mY =  fields.get(“y”, 0.0);
            mW =  fields.get(“w”, 0.0);
            mH =  fields.get(“h”, 0.0);
        }

        private void writeObject(ObjectOutputStream aOutputStream) throws IOException
        {
            aInputStream.writeLong(mId);
            aInputStream.writeUTF(mName);

            ObjectOutputStream .GetField fields = aOutputStream.putFields();
            mX = fields.put(“x”, 0.0);
            mY =  fields.put(“y”, 0.0);
            mW =  fields.put(“w”, 0.0);
            mH =  fields.put(“h”, 0.0);
            fields.writeFields();
        }
    }
  9. StringTokenizer
    Allow an application to break a string into tokens by performing code point comparison.
  10. xxx
阅读(2293) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~