Java Reference
In-Depth Information
}
StringBuilder xml = new StringBuilder("<?xml ver-
sion=\"1.0\"?>");
xml.append("<response>book updated</response>");
return
new
StreamSource(new
StringRead-
er(xml.toString()));
}
private Map<String, Book> deserialize() throws IOExcep-
tion
{
try (BufferedInputStream bis
=
new
BufferedInputStream(new
FileIn-
putStream(LIBFILE));
XMLDecoder xmld = new XMLDecoder(bis))
{
@SuppressWarnings("unchecked")
Map<String, Book> result = (Map<String, Book>) xm-
ld.readObject();
return result;
}
}
private void serialize() throws IOException
{
try (BufferedOutputStream bos
=
new
BufferedOutputStream(new
FileOut-
putStream(LIBFILE));
XMLEncoder xmle = new XMLEncoder(bos))
{
xmle.writeObject(library);
}
}
public static void main(String[] args)
{
Endpoint.publish("http://localhost:9902/library",
new Library());
Search WWH ::




Custom Search