Code example for ObjectInputStream

Methods: close, readObject

0
          throws ResourceCreationException, ResourceLoadingException 
  { 
    try 
    { 
      final InputStream in = data.getResourceAsStream(manager);
      final ObjectInputStream oin = new ObjectInputStream(in);
      try 
      { 
        final Object ob = oin.readObject();
        // yes, that will be more generic in the future ... 
        if (ob instanceof External8BitEncodingData == false)
        { 
          throw new ResourceCreationException("This is no 8Bit Encoding data"); 
        } 
        final External8BitEncodingData encData = (External8BitEncodingData) ob;
        final External8BitEncodingCore encCore =
                new External8BitEncodingCore(encData);
        return new SimpleResource(data.getKey(), encCore, getFactoryType(), data.getVersion(manager));
      } 
      finally 
      { 
        oin.close();
      } 
    } 
    catch (IOException e)
    { 
      throw new ResourceLoadingException("Failed to load resource", e);