List of usage examples for java.io ObjectInputStream readInt
public int readInt() throws IOException
From source file:de.unibayreuth.bayeos.goat.table.OctetMatrixTableModel.java
private void readStream(InputStream in, Vector objekts) throws IOException { int von = 0;// w ww. ja v a 2s . co m rowCount = 0; ObjectInputStream oin = new ObjectInputStream(in); try { while (true) { vonList.add(oin.readInt()); for (int c = 0; c < objekts.size(); c++) { wertList.add(oin.readObject()); } rowCount++; } } catch (EOFException i) { if (logger.isDebugEnabled()) { logger.debug("Stream with " + rowCount + " rows red."); } } catch (ClassNotFoundException e) { logger.error(e.getMessage()); } }
From source file:com.kynetx.api.java
protected CookieStore fetchCookies() { CookieStore toReturn = null;/* w w w.ja v a 2 s . com*/ int size = 0; if (isReadable() || isWritable()) { try { File path = new File(context.getExternalFilesDir(null), "cookies"); FileInputStream fin = new FileInputStream(path); ObjectInputStream ois = new ObjectInputStream(fin); size = ois.readInt(); toReturn = new BasicCookieStore(); for (int i = 0; i < size; i++) { BasicClientCookie cookie = new BasicClientCookie((String) ois.readObject(), (String) ois.readObject()); cookie.setDomain((String) ois.readObject()); cookie.setPath((String) ois.readObject()); cookie.setVersion(ois.readInt()); toReturn.addCookie((Cookie) cookie); } ois.close(); } catch (Exception e) { return null; } } if (size > 0) { return toReturn; } else { return null; } }
From source file:org.eclipse.ecr.runtime.api.ServiceHost.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject();/* w w w . ja v a2 s . co m*/ int len = in.readInt(); String[] ar = new String[len]; for (int i = 0; i < len; i++) { ar[i] = (String) in.readObject(); } setGroups(ar); }
From source file:com.cyberway.issue.crawler.datamodel.RobotsExclusionPolicy.java
/** If object is DENYALL or ALLOWALL, only the object identity and type * is read from the serialization stream. * * @param stream the serialization stream. * @throws IOException /*from www. j a va2 s. co m*/ * @throws ClassNotFoundException */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { type = stream.readInt(); if (type == NORMAL_TYPE) { stream.defaultReadObject(); } }
From source file:uk.ac.ebi.fg.jobs.JobController.java
/** * Retrieves ontology distance calculator object from file or creates new object in case EFO version or * ontology distance is different to file * * @param efo currently used EFO * @param maxOntologyDistance maximal ontology distance for ontology term distance calculations * @param fileLocation/* ww w .ja v a2 s.c om*/ * @return * @throws Exception */ private OntologyDistanceCalculator getOntologyDistanceCalculator(IEFO efo, int maxOntologyDistance, String fileLocation) throws Exception { String version = efo.getVersionInfo(); OntologyDistanceCalculator distCalc = null; File ontDistFile = new File(fileLocation); if (ontDistFile.exists()) { FileInputStream fis = new FileInputStream(ontDistFile); ObjectInputStream ois = new ObjectInputStream(fis); if ((ois.readInt() == maxOntologyDistance) && (ois.readUTF().equals(version))) { logger.info("Precalculated ontology distance file found for version " + version + " and distance " + maxOntologyDistance); distCalc = (OntologyDistanceCalculator) ois.readObject(); logger.info("\'ontology distance calculator\' object retrieved from file"); } ois.close(); } if (null == distCalc) { logger.info("Matching precalculated ontology distance file not found."); distCalc = new OntologyDistanceCalculator(efo, maxOntologyDistance); logger.info("Creating file " + ontDistFile); FileOutputStream fos = new FileOutputStream(ontDistFile); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeInt(maxOntologyDistance); oos.writeUTF(version); oos.writeObject(distCalc); oos.close(); logger.info("File " + ontDistFile + " successfully created"); } return distCalc; }
From source file:webplugin.WebAddress.java
public void readData(ObjectInputStream in) throws IOException, ClassNotFoundException { int version = in.readInt(); mName = (String) in.readObject(); mIconFileName = (String) in.readObject(); if (version == 2 && mIconFileName != null) { File iconFile = new File(mIconFileName); if (iconFile.isFile()) { mIconFileName = iconFile.getName(); } else {/*w w w.j a v a 2s. co m*/ mIconFileName = ""; } } mUrl = (String) in.readObject(); if (version == 1) { String encoding = (String) in.readObject(); mUrl = mUrl.replaceAll("\\{0\\}", "{urlencode(title, \"" + encoding + "\")}"); } mUserEntry = in.readBoolean(); mActive = in.readBoolean(); }
From source file:org.archive.modules.net.RobotsExclusionPolicy.java
/** If object is DENYALL or ALLOWALL, only the object identity and type * is read from the serialization stream. * * @param stream the serialization stream. * @throws IOException /*from ww w . jav a 2s. co m*/ * @throws ClassNotFoundException */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { int ordinal = stream.readInt(); type = Type.values()[ordinal]; if (type == Type.NORMAL) { stream.defaultReadObject(); } }
From source file:org.codehaus.wadi.core.store.DiscStore.java
public byte[] loadBody(Motable motable) throws Exception { File file = new File(sessionStoreDir, motable.getId() + streamer.getSuffixWithDot()); FileInputStream fis = null;/*from w w w . ja v a 2 s . c om*/ try { fis = new FileInputStream(file); ObjectInputStream ois = new ObjectInputStream(fis); ois.readLong(); ois.readLong(); ois.readInt(); ois.readObject(); int bodyLength = ois.readInt(); byte[] body = new byte[bodyLength]; fis.read(body); if (log.isTraceEnabled()) { log.trace("loaded exclusive disc: " + file + ": " + bodyLength + " bytes"); } return body; } catch (Exception e) { log.error("load exclusive disc failed: " + file, e); throw e; } finally { try { if (null != fis) { fis.close(); } } catch (IOException e) { log.warn("load exclusive disc problem: " + file, e); } } }
From source file:org.lenskit.mf.MFModel.java
private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException { featureCount = input.readInt(); userCount = input.readInt();/*w w w .j a v a2s . co m*/ itemCount = input.readInt(); RealMatrix umat = MatrixUtils.createRealMatrix(userCount, featureCount); for (int i = 0; i < userCount; i++) { for (int j = 0; j < featureCount; j++) { umat.setEntry(i, j, input.readDouble()); } } userMatrix = umat; RealMatrix imat = MatrixUtils.createRealMatrix(itemCount, featureCount); for (int i = 0; i < itemCount; i++) { for (int j = 0; j < featureCount; j++) { imat.setEntry(i, j, input.readDouble()); } } itemMatrix = imat; userIndex = (KeyIndex) input.readObject(); itemIndex = (KeyIndex) input.readObject(); if (userIndex.size() != userMatrix.getRowDimension()) { throw new InvalidObjectException("user matrix and index have different row counts"); } if (itemIndex.size() != itemMatrix.getRowDimension()) { throw new InvalidObjectException("item matrix and index have different row counts"); } }
From source file:org.review_board.ereviewboard.core.ReviewboardClientManager.java
private void readCache() { if (!cacheFile.exists()) { return;/*from ww w. j a va2 s .com*/ } ObjectInputStream in = null; try { in = new ObjectInputStream(new FileInputStream(cacheFile)); for (int count = in.readInt(); count > 0; count--) { String clientUrl = null; try { clientUrl = in.readObject().toString(); dataByUrl.put(clientUrl, (ReviewboardClientData) in.readObject()); } catch (IOException e) { logWarning("Could not read data for client with url " + clientUrl, e); } catch (ClassNotFoundException e) { logWarning("Could not read data for client with url " + clientUrl, e); } } } catch (IOException e) { logWarning("The Reviewboard respository data cache could not be read ", e); } catch (RuntimeException e) { logWarning("The Reviewboard respository data cache could not be read ", e); } finally { IOUtils.closeQuietly(in); } }