Posted on 2008-03-27 17:26 
leekiang 阅读(520) 
评论(0)  编辑  收藏  所属分类: 
java 
			 
			
		 
		1,oracle的blob的InputStream读过一次后,再执行reset时就会报错。而上传的附件的inputstream就不会。
java.io.IOException: Mark invalid or stream not marked.
    at oracle.jdbc.driver.OracleBlobInputStream.reset(OracleBlobInputStream.java:267)
2,
InputStream s = new BufferedInputStream(new FileInputStream("c:\\test"));
BufferedInputSream是可以使用mark及reset方法,使用上述的嵌套方法间接的使其它的stream也支持这些方法了。
3,以下代码有漏洞
public Object readObject(File file)
    {
        Object o = null;
        if (file.exists())
        {
            FileInputStream fis = null;
            ObjectInputStream ois = null;
            try
            {
                fis = new FileInputStream(file);
                ois = new ObjectInputStream(fis);
                o = ois.readObject();
            }
            catch (Throwable e)
            {
                e.printStackTrace();
            }
            finally
            {
                if (fis != null)
                {
                    try
                    {
                        fis.close();
                    }
                    catch (IOException e)
                    {
                        e.printStackTrace();
                    }
                }
            }            
        }
        return o;
    }
在IO的编程中一定要保存基本流的引用