List of usage examples for java.io ObjectInputStream readUTF
public String readUTF() throws IOException
From source file:com.qwazr.utils.server.InFileSessionPersistenceManager.java
private void readSessionAttribute(ObjectInputStream in, Map<String, Object> sessionData) throws IOException { final String attribute = in.readUTF(); try {/*w w w.j ava2 s .com*/ Object object = in.readObject(); if (!(object instanceof SerializationUtils.NullEmptyObject)) sessionData.put(attribute, object); } catch (ClassNotFoundException | NotSerializableException e) { if (logger.isWarnEnabled()) logger.warn("The attribute " + attribute + " cannot be deserialized: " + e.getMessage(), e); } }
From source file:it.jackbergus.graphdatabase.graph.PropertyGraph.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { relationName = in.readUTF(); core = new GuavaMatrix(relationName); }
From source file:com.qwazr.server.InFileSessionPersistenceManager.java
private void readSessionAttribute(final ObjectInputStream in, final Map<String, Object> sessionData) throws IOException { final String attribute = in.readUTF(); try {//from w w w.j ava 2s . c o m sessionData.put(attribute, in.readObject()); } catch (ClassNotFoundException | NotSerializableException e) { LOGGER.log(Level.WARNING, e, () -> "The attribute " + attribute + " cannot be deserialized"); } }
From source file:it.unibo.alchemist.language.protelis.MethodCall.java
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject();//from w w w. j a v a 2 s . com final Class<?> declaringClass = (Class<?>) in.readObject(); final String methodName = in.readUTF(); final Class<?>[] parameterTypes = (Class<?>[]) in.readObject(); try { method = declaringClass.getMethod(methodName, parameterTypes); } catch (Exception e) { throw new IOException(String.format("Error occurred resolving deserialized method '%s.%s'", declaringClass.getSimpleName(), methodName), e); } }
From source file:org.apache.hc.client5.http.impl.auth.BasicScheme.java
@SuppressWarnings("unchecked") private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject();//from www . ja v a 2 s . c o m try { this.charset = Charset.forName(in.readUTF()); } catch (final UnsupportedCharsetException ex) { this.charset = StandardCharsets.US_ASCII; } }
From source file:org.jbpm.integration.cmis.impl.OpenCMISPlaceholderResolverStrategy.java
public Object read(ObjectInputStream os) throws IOException, ClassNotFoundException { String objectId = os.readUTF(); String canonicalName = os.readUTF(); Session session = getRepositorySession(user, password, url, repository); try {//from www . j av a 2s .co m org.apache.chemistry.opencmis.client.api.Document doc = (org.apache.chemistry.opencmis.client.api.Document) findObjectForId( session, objectId); Document document = (Document) Class.forName(canonicalName).newInstance(); document.setIdentifier(objectId); document.setName(doc.getName()); document.addAttribute("location", getFolderName(doc.getParents()) + getPathAsString(doc.getPaths())); if (doc.getContentStream() != null) { ContentStream stream = doc.getContentStream(); document.setContent(IOUtils.toByteArray(stream.getStream())); document.addAttribute("updated", "false"); document.addAttribute("type", stream.getMimeType()); } return document; } catch (Exception e) { throw new RuntimeException("Cannot read document from CMIS", e); } finally { session.clear(); } }
From source file:com.izforge.izpack.uninstaller.resource.RootScripts.java
/** * Returns the root scripts./*from w ww. ja v a 2 s. c o m*/ * * @return the root scripts * @throws IzPackException if a resource cannot be read */ private List<String> getRootScripts(Resources resources) { List<String> result = new ArrayList<String>(); for (int index = 0;; ++index) { try { String name = UninstallData.ROOTSCRIPT + Integer.toString(index); ObjectInputStream in = null; try { InputStream inputStream = resources.getInputStream(name); in = new ObjectInputStream(inputStream); result.add(in.readUTF()); } catch (IOException exception) { throw new IzPackException("Failed to read resource: " + name, exception); } finally { IOUtils.closeQuietly(in); } } catch (ResourceNotFoundException ignore) { break; } } return result; }
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/* w w w . j ava2 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:eu.stratosphere.hadoopcompatibility.mapred.HadoopInputFormat.java
@SuppressWarnings("unchecked") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { String hadoopInputFormatClassName = in.readUTF(); String keyClassName = in.readUTF(); String valueClassName = in.readUTF(); if (jobConf == null) { jobConf = new JobConf(); }/*from w ww .ja v a2 s.com*/ jobConf.readFields(in); try { this.mapredInputFormat = (org.apache.hadoop.mapred.InputFormat<K, V>) Class .forName(hadoopInputFormatClassName, true, Thread.currentThread().getContextClassLoader()) .newInstance(); } catch (Exception e) { throw new RuntimeException("Unable to instantiate the hadoop input format", e); } try { this.keyClass = (Class<K>) Class.forName(keyClassName, true, Thread.currentThread().getContextClassLoader()); } catch (Exception e) { throw new RuntimeException("Unable to find key class.", e); } try { this.valueClass = (Class<V>) Class.forName(valueClassName, true, Thread.currentThread().getContextClassLoader()); } catch (Exception e) { throw new RuntimeException("Unable to find value class.", e); } ReflectionUtils.setConf(mapredInputFormat, jobConf); }
From source file:com.mgmtp.jfunk.common.util.Configuration.java
private void readObject(final ObjectInputStream ois) throws IOException, ClassNotFoundException { ois.defaultReadObject();/*from w w w . j a v a 2s . c o m*/ String zipFileName = ois.readUTF(); zipArchive = new ZipFile(zipFileName); }