Posted on 2008-03-27 17:26
leekiang 閱讀(513)
評論(0) 編輯 收藏 所屬分類:
java
1,oracle的blob的InputStream讀過一次后,再執(zhí)行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的編程中一定要保存基本流的引用