📄 dbcachereader.java
字号:
/* DBCacheReader.java (P)1999-2001 Laurentiu Cristofor*//*laur.dm.ar - A Java package for association rule mining Copyright (C) 2002 Laurentiu CristoforThis program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or (atyour option) any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USAThe laur.dm.ar package was written by Laurentiu Cristofor (laur@cs.umb.edu).*/package laur.dm.ar;import java.io.*;/** A DBCacheReader deserializes itemsets from cache. @version 1.0 @author Laurentiu Cristofor*/public class DBCacheReader{ private ObjectInputStream instream ; private String filename; /** * Initializes a DBCacheReader to read from the specified cache file. * * @param name name of the cache file * @exception IllegalArgumentException <code>name</code> is null * @exception IOException from java.io package */ public DBCacheReader(String name) throws IOException { if (name == null) throw new IllegalArgumentException("Constructor argument must be non null"); filename = name; instream = new ObjectInputStream(new FileInputStream(filename)); } /** * Closes the cache file. * * @exception IOException from java.io package */ public void close() throws IOException { instream.close(); } /** * Return the first itemset from cache. * * @exception IOException from java.io package * @exception ClassNotFoundException from java.io package * @return first itemset in cache */ public Itemset getFirstItemset() throws IOException, ClassNotFoundException { instream.close(); instream = new ObjectInputStream(new FileInputStream(filename)); return ((Itemset)instream.readObject()); } /** * Return next itemset from cache. * * @exception EOFException from java.io package, when end of cache * is reached * @exception IOException from java.io package * @exception ClassNotFoundException from java.io package * @return next itemset in cache */ public Itemset getNextItemset() throws IOException, ClassNotFoundException { return ((Itemset)instream.readObject()); } /** * sample usage and testing */ public static void main(String[] args) { try { DBCacheReader dbcache = new DBCacheReader("test.cache"); try { while (true) System.out.println(dbcache.getNextItemset()); } catch (EOFException e) { dbcache.close(); } } catch (Exception e) { System.out.println(e); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -