- private void writeLine(OutputStream out, String line) throws IOException {
- if (crypt == null) {
- out.write(line.getBytes());
- bytesSent += line.length();
- } else {
- // TODO: how NOT to create so many big Strings?
- String b64 = crypt.encrypt64(line, false);
- out.write(b64.getBytes());
- bytesSent += b64.length();
+ @SuppressWarnings("resource")
+ private Object rec(boolean asString) throws IOException,
+ NoSuchFieldException, NoSuchMethodException,
+ ClassNotFoundException, java.lang.NullPointerException {
+
+ synchronized (lock) {
+ if (server || contentToSend) {
+ if (contentToSend) {
+ out.flush();
+ contentToSend = false;
+ }
+
+ if (in.next() && !in.eof()) {
+ InputStream read = new ReplaceInputStream(in.open(),
+ STREAM_CODED, STREAM_RAW);
+ try {
+ if (crypt != null) {
+ read = crypt.decrypt64(read);
+ }
+
+ if (asString) {
+ return IOUtils.readSmallStream(read);
+ }
+
+ return new Importer().read(read).getValue();
+ } finally {
+ read.close();
+ }
+ }
+
+ if (!asString) {
+ throw new NullPointerException();
+ }
+ }
+
+ return null;