List of usage examples for java.io ObjectInputStream readInt
public int readInt() throws IOException
From source file:pt.webdetails.cda.cache.TableCacheKey.java
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { //to be hazelcast compatible needs to serialize EXACTLY the same //binary comparison/hash will be used //connection/*from w ww . jav a 2 s.c o m*/ connectionHash = in.readInt(); //query query = (String) in.readObject(); //queryTpe queryType = (String) in.readObject(); int len = in.readInt(); Parameter[] params = new Parameter[len]; for (int i = 0; i < params.length; i++) { Parameter param = new Parameter(); param.readObject(in); params[i] = param; } parameters = params; extraCacheKey = (Serializable) in.readObject(); }
From source file:org.apache.flink.streaming.api.state.NullableCircularBuffer.java
/** * Read the buffer in using a custom routine. * //from w ww.ja va2s . co m * @param in * the input stream * @throws IOException * @throws ClassNotFoundException */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); elements = new Object[maxElements]; int size = in.readInt(); for (int i = 0; i < size; i++) { elements[i] = in.readObject(); } start = 0; full = (size == maxElements); if (full) { end = 0; } else { end = size; } }
From source file:org.codehaus.wadi.core.store.DiscStore.java
public void load(Putter putter) { long time = System.currentTimeMillis(); String[] list = sessionStoreDir.list(); int suffixLength = ".".length() + streamer.getSuffix().length(); for (int i = 0; i < list.length; i++) { String name = list[i];//w w w .j a v a 2 s.c om String id = name.substring(0, name.length() - suffixLength); Motable motable = new BasicStoreMotable(this); File file = new File(sessionStoreDir, id + streamer.getSuffixWithDot()); FileInputStream fis = null; ObjectInputStream ois = null; try { fis = new FileInputStream(file); ois = new ObjectInputStream(fis); long creationTime = ois.readLong(); long lastAccessedTime = ois.readLong(); int maxInactiveInterval = ois.readInt(); name = (String) ois.readObject(); motable.init(creationTime, lastAccessedTime, maxInactiveInterval, name); if (accessOnLoad) { motable.setLastAccessedTime(time); } if (!motable.getTimedOut(time)) { putter.put(id, motable); } } catch (Exception e) { log.warn("load (exclusive disc) failed [" + file + "]", e); } finally { try { if (null != ois) { ois.close(); } } catch (IOException e) { log.warn("load (exclusive disc) problem [" + file + "]", e); } } } log.info("loaded (exclusive disc): " + list.length); }
From source file:org.mrgeo.data.raster.RasterWritable.java
private synchronized void readObject(ObjectInputStream stream) throws IOException { int size = stream.readInt(); byte[] bytes = new byte[size]; stream.readFully(bytes, 0, size);/*from w ww . ja v a 2 s .com*/ set(bytes, 0, size); }
From source file:be.fgov.kszbcss.rhq.websphere.config.cache.ConfigQueryCache.java
public void start(int numThreads) { synchronized (cache) { if (threads != null || stopping) { // start has already been called before throw new IllegalStateException(); }/*from w w w .j a v a 2 s . co m*/ if (persistentFile.exists()) { if (log.isDebugEnabled()) { log.debug("Reading persistent cache " + persistentFile); } try { ObjectInputStream in = new ObjectInputStream(new FileInputStream(persistentFile)); try { for (int i = in.readInt(); i > 0; i--) { ConfigQueryCacheEntry<?> entry = (ConfigQueryCacheEntry<?>) in.readObject(); cache.put(entry.query, entry); } } finally { in.close(); } } catch (IOException ex) { log.error("Failed to read persistent cache data", ex); } catch (ClassNotFoundException ex) { log.error("Unexpected exception", ex); } } } if (log.isDebugEnabled()) { log.debug("Starting " + numThreads + " worker threads"); } threads = new Thread[numThreads]; for (int i = 0; i < numThreads; i++) { Thread thread = new Thread(this, name + "-query-" + (i + 1)); threads[i] = thread; thread.start(); } timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { persist(); } }, 5 * 60 * 1000); // TODO: need another timer that removes entries that are no longer used! }
From source file:de.flyingsnail.ipv6droid.android.MainActivity.java
/** Read from a private file. If no such file exists, fall back to currently active tunnel. */ private TicTunnel loadPersistedTunnel() { TicTunnel tunnel = statusReceiver.getTunnel(); try {/*from w w w . ja va2s .c o m*/ // open private file InputStream is = openFileInput(FILE_LAST_TUNNEL); ObjectInputStream os = new ObjectInputStream(is); List<TicTunnel> tunnels = (List<TicTunnel>) os.readObject(); int selected = os.readInt(); tunnel = tunnels.get(selected); } catch (Exception e) { Log.e(TAG, "Could not retrieve saved state of TicTunnel", e); } return tunnel; }
From source file:org.mrgeo.hdfs.vector.shp.ShapefileReader.java
@SuppressFBWarnings(value = { "WEAK_FILENAMEUTILS", "PATH_TRAVERSAL_IN" }, justification = "Correctly filtered parameters") private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException { fileName = in.readUTF();/*from w ww . j a v a 2 s. c o m*/ source = Source.values()[in.readInt()]; if (source == Source.FILE) { File f = new File(FilenameUtils.getFullPath(fileName), FilenameUtils.getName(fileName)); if (f.exists()) { load(fileName); } } else { if (HadoopFileUtils.exists(fileName)) { load(new Path(fileName)); } } }
From source file:xbird.engine.remote.RemoteFocus.java
private int fetchInternal(InputStream is) { final ObjectInputStream ois; final int fetchedLength; try {/*from w w w . j a va 2s . c o m*/ ois = new ObjectInputStream(is); fetchedLength = ois.readInt(); } catch (IOException ioe) { throw new XQRTException("failed to deserialize the fetched items", ioe); } try { for (int i = 0; i < fetchedLength; i++) { Object ro = ois.readObject(); Item fetched = (Item) ro; _fetchedQueue.offer(fetched); } } catch (IOException ioe) { throw new XQRTException("failed to deserialize the fetched items", ioe); } catch (ClassNotFoundException cnf) { throw new XQRTException("failed to deserialize the fetched items", cnf); } return fetchedLength; }
From source file:cn.com.loopj.android.http.SerializableCookie.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { String key = (String) in.readObject(); String value = (String) in.readObject(); clientCookie = new BasicClientCookie(key, value); clientCookie.setComment((String) in.readObject()); clientCookie.setDomain((String) in.readObject()); clientCookie.setExpiryDate((Date) in.readObject()); clientCookie.setPath((String) in.readObject()); clientCookie.setVersion(in.readInt()); clientCookie.setSecure(in.readBoolean()); }
From source file:cn.caimatou.canting.utils.http.asynchttp.SerializableCookie.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { String name = (String) in.readObject(); String value = (String) in.readObject(); clientCookie = new BasicClientCookie(name, value); clientCookie.setComment((String) in.readObject()); clientCookie.setDomain((String) in.readObject()); clientCookie.setExpiryDate((Date) in.readObject()); clientCookie.setPath((String) in.readObject()); clientCookie.setVersion(in.readInt()); clientCookie.setSecure(in.readBoolean()); }