@@ -0,0 +1,3545 @@
+/*%0A * Copyright (c) 2006-2011 Chris Smith, Shane Mc Cormack, Gregory Holmes%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a copy%0A * of this software and associated documentation files (the %22Software%22), to deal%0A * in the Software without restriction, including without limitation the rights%0A * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0A * copies of the Software, and to permit persons to whom the Software is%0A * furnished to do so, subject to the following conditions:%0A *%0A * The above copyright notice and this permission notice shall be included in%0A * all copies or substantial portions of the Software.%0A *%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0A * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0A * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE%0A * SOFTWARE.%0A */%0A%0Apackage com.dmdirc.util;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.util.List;%0A%0A/**%0A * Simple stream reader to read a stream and save/discard the data.%0A */%0Apublic class StreamReader extends Thread %7B%0A%0A    /** This is the Input Stream we are reading. */%0A    private InputStream stream;%0A%0A    /** List to store output in. */%0A    private List%3CString%3E list = null;%0A%0A    /** StringBuffer to store output in. */%0A    private StringBuffer buffer = null;%0A%0A    /**%0A     * Create a new Stream Reader that discards output.%0A     *%0A     * @param stream The stream to read%0A     */%0A    public StreamReader(final InputStream stream) %7B%0A        super(%22StreamReader%22);%0A%0A        this.stream = stream;%0A    %7D%0A%0A    /**%0A     * Create a new Stream Reader that outputs to a List.%0A     *%0A     * @param stream The stream to read%0A     * @param list The list to store the output from the stream in%0A     */%0A    public StreamReader(final InputStream stream, final List%3CString%3E list) %7B%0A        super(%22StreamReader%22);%0A%0A        this.stream = stream;%0A        this.list = list;%0A    %7D%0A%0A    /**%0A     * Create a new Stream Reader that outputs to a StringBuffer.%0A     *%0A     * @param stream The stream to read%0A     * @param buffer The StringBuffer to store the output from the stream in%0A     */%0A    public StreamReader(final InputStream stream, final StringBuffer buffer) %7B%0A        super(%22StreamReader%22);%0A%0A        this.stream = stream;%0A        this.buffer = buffer;%0A    %7D%0A%0A    /**%0A     * Get the list that the output is being stored in.%0A     *%0A     * @return The output list%0A     */%0A    public List%3CString%3E getList() %7B%0A        return list;%0A    %7D%0A%0A    /**%0A     * Wait for input on stream, and output/throw away/save to list%0A     */%0A    @Override%0A    public void run() %7B%0A        BufferedReader reader = new BufferedReader(new InputStreamReader(stream));%0A        try %7B%0A            String line;%0A            while ((line = reader.readLine()) != null) %7B%0A                if (list != null) %7B%0A                    list.add(line);%0A                %7D else if (buffer != null) %7B%0A                    if (buffer.length() %3E 0) %7B buffer.append('%5Cn'); %7D%0A                    buffer.append(line);%0A                %7D%0A            %7D%0A        %7D catch (IOException ex) %7B%0A            // OH WELL%0A        %7D finally %7B%0A            StreamUtil.close(stream);%0A        %7D%0A    %7D%0A%7D%0A

Move StreamReader to util.