List of usage examples for java.io ObjectInputStream readObject
public final Object readObject() throws IOException, ClassNotFoundException
From source file:common.services.generic.GenericCacheService.java
@Override public T getFromFile() { File f = new File(path, "cache.tmp"); if (!f.exists()) return null; try {//from ww w.j a va 2 s. c o m FileInputStream fi = new FileInputStream(f); ObjectInputStream si = new ObjectInputStream(fi); T tmp = (T) si.readObject(); si.close(); fi.close(); return tmp; } catch (IOException ex) { logger.error("failed to load cache path = " + path, ex); return null; } catch (ClassNotFoundException ex) { logger.error("failed to load cache path = " + path, ex); return null; } }
From source file:net.mindengine.oculus.frontend.web.controllers.report.SavedReportController.java
@SuppressWarnings("unchecked") private List<TestRunSearchData> getSavedTestRuns(SavedRun savedRun) throws Exception { List<TestRunSearchData> testRuns; File file = new File(config.getDataFolder() + File.separator + savedRun.generateFileUrl()); FileInputStream fis = new FileInputStream(file); ObjectInputStream ois = new ObjectInputStream(fis); testRuns = (List<TestRunSearchData>) ois.readObject(); return testRuns; }
From source file:com.limegroup.gnutella.licenses.WeedLicenseTest.java
public void testSerializeAndDeserialize() throws Exception { License l = new StubWeedLicense("3", "4", "page"); assertEquals(null, l.getLicense());/*from ww w . j ava2 s . c o m*/ assertEquals("http://weedshare.com/company/policies/summary_usage_rights.aspx", l.getLicenseDeed(null).toString()); assertEquals("http://www.weedshare.com/license/verify_usage_rights.aspx?versionid=4&contentid=3", l.getLicenseURI().toString()); assertEquals("Details unknown.", l.getLicenseDescription(null)); assertFalse(l.isVerified()); assertFalse(l.isValid(null)); ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bout); out.writeObject(l); ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); ObjectInputStream in = new ObjectInputStream(bin); l = (License) in.readObject(); assertEquals(null, l.getLicense()); // CHANGE -- not serialized (but unused anyway) assertEquals("http://weedshare.com/company/policies/summary_usage_rights.aspx", l.getLicenseDeed(null).toString()); assertEquals(null, l.getLicenseURI()); // CHANGE -- not serialized assertEquals("Details unknown.", l.getLicenseDescription(null)); assertTrue(l.isVerified()); // CHANGE -- becomes verified assertFalse(l.isValid(null)); // Now try with a full out parsed License. l = new StubWeedLicense("3", "4", xml(true, "Sammy B", "Blues In G", "$4.20")); l.verify(null); assertEquals(null, l.getLicense()); assertTrue(l.isVerified()); assertTrue(l.isValid(null)); assertEquals("http://weedshare.com/company/policies/summary_usage_rights.aspx", l.getLicenseDeed(null).toString()); assertEquals("Artist: Sammy B\nTitle: Blues In G\nPrice: $4.20", l.getLicenseDescription(null)); bout = new ByteArrayOutputStream(); out = new ObjectOutputStream(bout); out.writeObject(l); bin = new ByteArrayInputStream(bout.toByteArray()); in = new ObjectInputStream(bin); l = (License) in.readObject(); assertEquals(null, l.getLicense()); // CHANGE -- not serialized (but unused) assertTrue(l.isVerified()); assertTrue(l.isValid(null)); assertEquals("http://weedshare.com/company/policies/summary_usage_rights.aspx", l.getLicenseDeed(null).toString()); assertEquals("Artist: Sammy B\nTitle: Blues In G\nPrice: $4.20", l.getLicenseDescription(null)); }
From source file:com.adobe.acs.commons.httpcache.config.impl.keys.KeyValueCacheKey.java
/** For De-serialization **/ private void readObject(ObjectInputStream o) throws IOException, ClassNotFoundException { parentReadObject(o);//w w w . j a v a 2s . c om allowedKeyValues = (Map<String, String[]>) o.readObject(); }
From source file:net.javacoding.jspider.core.task.work.SerializableSpiderHttpURLTask.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject();//from www. j a v a 2 s . c o m this.foundURL = (URL) in.readObject(); this.contextToString = (String) in.readObject(); this.context = contexts.get(contextToString); if (this.context == null) { throw new IOException("Not find context !"); } }
From source file:com.sun.j2ee.blueprints.waf.controller.impl.ClientStateFlowHandler.java
public String processFlow(HttpServletRequest request) throws FlowHandlerException { String forwardScreen = request.getParameter("referring_screen"); // de-serialize the request attributes. Map params = (Map) request.getParameterMap(); HashMap newParams = new HashMap(); String cacheId = request.getParameter("cacheId"); if (!params.isEmpty()) { Iterator it = params.keySet().iterator(); // put the request attributes stored in the session in the request while (it.hasNext()) { String key = (String) it.next(); if (key.startsWith(cacheId + "_attribute_")) { String[] values = (String[]) params.get(key); String valueString = values[0]; byte[] bytes = Base64.decode(valueString.getBytes()); try { ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes)); Object requestObject = requestObject = ois.readObject(); ois.close();/*from w ww. j a v a 2s.c om*/ // put the de-serialized object back into the request String requestObjectKey = key.substring((cacheId + "_attribute_").length(), key.length()); request.setAttribute(requestObjectKey, requestObject); } catch (java.io.OptionalDataException ode) { logger.error("ClientCacheLinkFlowHandler caught: ", ode); } catch (java.lang.ClassNotFoundException cnfe) { logger.error("ClientCacheLinkFlowHandler caught: ", cnfe); } catch (java.io.IOException iox) { logger.error("ClientCacheLinkFlowHandler caught: ", iox); } } } } return forwardScreen; }
From source file:com.ps.cc.controller.Init.java
@RequestMapping public String index(ModelMap map, RenderRequest renderRequest) throws Exception { TwilioConfiguration twilioConfiguration = new TwilioConfiguration(); try {//from www. j av a 2s. c o m File file = new File("twilioConfiguration.txt"); ObjectInputStream in = new ObjectInputStream(new FileInputStream(file)); twilioConfiguration = (TwilioConfiguration) in.readObject(); in.close(); } catch (Exception ex) { //didn't exist... } map.addAttribute("command", twilioConfiguration); return "index"; }
From source file:com.googlecode.DownloadCache.java
private void loadIndex() throws Exception { if (this.indexFile.isFile()) { FileInputStream input = new FileInputStream(this.indexFile); ObjectInputStream deserialize = new ObjectInputStream(input); this.index = (Map<String, CachedFileEntry>) deserialize.readObject(); deserialize.close();//from ww w.ja v a2s . c o m } else { this.index = new HashMap<String, CachedFileEntry>(); } }
From source file:slina.mb.controller.ObjectSaverFactory.java
@Test public void testDeserilization() throws IOException, ClassNotFoundException { InputStream osx = new FileInputStream("logEvent.ser"); ObjectInputStream ocm = new ObjectInputStream(osx); @SuppressWarnings("unchecked") ArrayList<LogEvent> yy = (ArrayList<LogEvent>) ocm.readObject(); ocm.close();/*from w w w . j a v a 2s. c o m*/ assertEquals(7, yy.size()); }
From source file:com.adobe.acs.commons.httpcache.config.impl.keys.GroupCacheKey.java
/** For De serialization **/ private void readObject(ObjectInputStream o) throws IOException, ClassNotFoundException { parentReadObject(o);//from www. java2 s .co m final String userGroupsStr = (String) o.readObject(); final String[] userGroupStrArray = userGroupsStr.split(","); cacheKeyUserGroups = Arrays.asList(userGroupStrArray); }