type = type.substring(0, type.length() - 2); // remove the []
write(out, type);
- write(out, "\r");
try {
for (int i = 0; true; i++) {
Object item = Array.get(value, i);
+
// encode it normally if direct value
+ write(out, "\r");
if (!SerialUtils.encode(out, item)) {
try {
// TODO: bad escaping?
.getMessage());
}
}
- write(out, "\r");
}
} catch (ArrayIndexOutOfBoundsException e) {
// Done.
in.close();
}
} finally {
- encoded.close();
+ encoded.flush();
+ // Cannot close!
}
}
@Override
protected Object fromStream(InputStream in) throws IOException {
try {
- return new Image(in);
+ // Cannot close it!
+ InputStream decoded = StringUtils.unbase64(in, false);
+ return new Image(decoded);
} catch (IOException e) {
throw new UnknownFormatConversionException(e.getMessage());
}
e.printStackTrace(); // should not happen (see
// setAccessible)
}
+
+ write(out, "\n}");
}
- write(out, "\n}");
}
/**
if (e instanceof IOException) {
throw (IOException) e;
}
- throw new IOException(e.getMessage());
+ throw new IOException(e.getMessage(), e);
}
}