diff -r ed84c8bdd87b -r 73b21e9f3958 src/org/sonews/util/io/ArticleInputStream.java --- a/src/org/sonews/util/io/ArticleInputStream.java Sun Aug 29 17:28:58 2010 +0200 +++ b/src/org/sonews/util/io/ArticleInputStream.java Mon Aug 30 00:20:06 2010 +0200 @@ -32,40 +32,36 @@ public class ArticleInputStream extends InputStream { - private byte[] buf; - private int pos = 0; - - public ArticleInputStream(final Article art) - throws IOException, UnsupportedEncodingException - { - final ByteArrayOutputStream out = new ByteArrayOutputStream(); - out.write(art.getHeaderSource().getBytes("UTF-8")); - out.write("\r\n\r\n".getBytes()); - out.write(art.getBody()); // Without CRLF - out.flush(); - this.buf = out.toByteArray(); - } + private byte[] buf; + private int pos = 0; - /** - * This method reads one byte from the stream. The pos - * counter is advanced to the next byte to be read. The byte read is - * returned as an int in the range of 0-255. If the stream position - * is already at the end of the buffer, no byte is read and a -1 is - * returned in order to indicate the end of the stream. - * - * @return The byte read, or -1 if end of stream - */ - @Override - public synchronized int read() - { - if(pos < buf.length) - { - return ((int)buf[pos++]) & 0xFF; - } - else - { - return -1; - } - } - + public ArticleInputStream(final Article art) + throws IOException, UnsupportedEncodingException + { + final ByteArrayOutputStream out = new ByteArrayOutputStream(); + out.write(art.getHeaderSource().getBytes("UTF-8")); + out.write("\r\n\r\n".getBytes()); + out.write(art.getBody()); // Without CRLF + out.flush(); + this.buf = out.toByteArray(); + } + + /** + * This method reads one byte from the stream. The pos + * counter is advanced to the next byte to be read. The byte read is + * returned as an int in the range of 0-255. If the stream position + * is already at the end of the buffer, no byte is read and a -1 is + * returned in order to indicate the end of the stream. + * + * @return The byte read, or -1 if end of stream + */ + @Override + public synchronized int read() + { + if (pos < buf.length) { + return ((int) buf[pos++]) & 0xFF; + } else { + return -1; + } + } }