// Path: src/main/java/de/todesbaum/util/io/LineInputStream.java
// public class LineInputStream extends FilterInputStream {
// 
// 	private boolean skipLinefeed = false;
// 	private StringBuffer lineBuffer = new StringBuffer();
// 
// 	/**
// 	 * @param in
// 	 */
// 	public LineInputStream(InputStream in) {
// 		super(in);
// 	}
// 
// 	public synchronized String readLine() throws IOException {
// 		lineBuffer.setLength(0);
// 		int c = 0;
// 		while (c != -1) {
// 			c = read();
// 			if ((c == -1) && lineBuffer.length() == 0)
// 				return null;
// 			if (skipLinefeed && (c == '\n')) {
// 				skipLinefeed = false;
// 				continue;
// 			}
// 			skipLinefeed = (c == '\r');
// 			if ((c == '\r') || (c == '\n')) {
// 				c = -1;
// 			} else {
// 				lineBuffer.append((char) c);
// 			}
// 		}
// 		return lineBuffer.toString();
// 	}
// 
// }
// 
// Path: src/main/java/de/todesbaum/util/io/TempFileInputStream.java
// public class TempFileInputStream extends FileInputStream {
// 
// 	private File tempFile;
// 
// 	/**
// 	 * @param name
// 	 * @throws FileNotFoundException
// 	 */
// 	public TempFileInputStream(String name) throws FileNotFoundException {
// 		this(new File(name));
// 	}
// 
// 	/**
// 	 * @param file
// 	 * @throws FileNotFoundException
// 	 */
// 	public TempFileInputStream(File file) throws FileNotFoundException {
// 		super(file);
// 		tempFile = file;
// 	}
// 
// 	@Override
// 	public void close() throws IOException {
// 		super.close();
// 		tempFile.delete();
// 	}
// 
// }


import net.pterodactylus.util.io.Closer;
import net.pterodactylus.util.io.StreamCopier;
import net.pterodactylus.util.io.StreamCopier.ProgressListener;
import de.todesbaum.util.io.LineInputStream;
import de.todesbaum.util.io.TempFileInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.Socket;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
	/**
	 * The reader thread for this connection. This is essentially a thread that
	 * reads lines from the node, creates messages from them and notifies
	 * listeners about the messages.
	 *
	 * @author David Roden &lt;droden@gmail.com&gt;
	 * @version $Id$
	 */
	private class NodeReader implements Runnable {

		/** The input stream to read from. */
		@SuppressWarnings("hiding")
		private InputStream nodeInputStream;

		/**
		 * Creates a new reader that reads from the specified input stream.
		 *
		 * @param nodeInputStream
		 *            The input stream to read from
		 */
		public NodeReader(InputStream nodeInputStream) {
			this.nodeInputStream = nodeInputStream;
		}

		/**
		 * Main loop of the reader. Lines are read and converted into
		 * {@link Message} objects.
		 */
		@SuppressWarnings("synthetic-access")
		public void run() {
// Path: src/main/java/de/todesbaum/util/io/LineInputStream.java
// public class LineInputStream extends FilterInputStream {
// 
// 	private boolean skipLinefeed = false;
// 	private StringBuffer lineBuffer = new StringBuffer();
// 
// 	/**
// 	 * @param in
// 	 */
// 	public LineInputStream(InputStream in) {
// 		super(in);
// 	}
// 
// 	public synchronized String readLine() throws IOException {
// 		lineBuffer.setLength(0);
// 		int c = 0;
// 		while (c != -1) {
// 			c = read();
// 			if ((c == -1) && lineBuffer.length() == 0)
// 				return null;
// 			if (skipLinefeed && (c == '\n')) {
// 				skipLinefeed = false;
// 				continue;
// 			}
// 			skipLinefeed = (c == '\r');
// 			if ((c == '\r') || (c == '\n')) {
// 				c = -1;
// 			} else {
// 				lineBuffer.append((char) c);
// 			}
// 		}
// 		return lineBuffer.toString();
// 	}
// 
// }
// 
// Path: src/main/java/de/todesbaum/util/io/TempFileInputStream.java
// public class TempFileInputStream extends FileInputStream {
// 
// 	private File tempFile;
// 
// 	/**
// 	 * @param name
// 	 * @throws FileNotFoundException
// 	 */
// 	public TempFileInputStream(String name) throws FileNotFoundException {
// 		this(new File(name));
// 	}
// 
// 	/**
// 	 * @param file
// 	 * @throws FileNotFoundException
// 	 */
// 	public TempFileInputStream(File file) throws FileNotFoundException {
// 		super(file);
// 		tempFile = file;
// 	}
// 
// 	@Override
// 	public void close() throws IOException {
// 		super.close();
// 		tempFile.delete();
// 	}
// 
// }


// Path: src/main/java/de/todesbaum/util/freenet/fcp2/Connection.java
import net.pterodactylus.util.io.Closer;
import net.pterodactylus.util.io.StreamCopier;
import net.pterodactylus.util.io.StreamCopier.ProgressListener;
import de.todesbaum.util.io.LineInputStream;
import de.todesbaum.util.io.TempFileInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.Socket;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

	/**
	 * The reader thread for this connection. This is essentially a thread that
	 * reads lines from the node, creates messages from them and notifies
	 * listeners about the messages.
	 *
	 * @author David Roden &lt;droden@gmail.com&gt;
	 * @version $Id$
	 */
	private class NodeReader implements Runnable {

		/** The input stream to read from. */
		@SuppressWarnings("hiding")
		private InputStream nodeInputStream;

		/**
		 * Creates a new reader that reads from the specified input stream.
		 *
		 * @param nodeInputStream
		 *            The input stream to read from
		 */
		public NodeReader(InputStream nodeInputStream) {
			this.nodeInputStream = nodeInputStream;
		}

		/**
		 * Main loop of the reader. Lines are read and converted into
		 * {@link Message} objects.
		 */
		@SuppressWarnings("synthetic-access")
		public void run() {
			LineInputStream nodeReader = null;