@@ -0,0 +1,1855 @@
+package inlein.client.io;%0A%0Aimport java.io.*;%0Aimport java.util.*;%0A%0Apublic final class BencodeWriter %7B%0A    private OutputStream out;%0A%0A    public BencodeWriter(OutputStream out) %7B%0A        this.out = out;%0A    %7D%0A%0A    public void writeString(String s) throws IOException %7B%0A        byte%5B%5D bs = s.getBytes(%22UTF-8%22);%0A        byte%5B%5D bsLen = new Integer(bs.length).toString().getBytes(%22UTF-8%22);%0A        out.write(bsLen);%0A        out.write(':');%0A        out.write(bs);%0A    %7D%0A%0A    public void writeLong(long l) throws IOException %7B%0A        byte%5B%5D bs = new Long(l).toString().getBytes(%22UTF-8%22);%0A        out.write('i');%0A        out.write(bs);%0A        out.write('e');%0A    %7D%0A%0A    public void writeList(List%3CObject%3E list) throws IOException %7B%0A        out.write('l');%0A        for (Object elem : list) %7B%0A            write(elem);%0A        %7D%0A        out.write('e');%0A    %7D%0A%0A    public void writeDict(Map%3CString, Object%3E map) throws IOException %7B%0A        out.write('d');%0A        for (Map.Entry%3CString, Object%3E entry : map.entrySet()) %7B%0A            writeString(entry.getKey());%0A            write(entry.getValue());%0A        %7D%0A        out.write('e');%0A    %7D%0A%0A    public void write(Object o) throws IOException %7B%0A        if (o instanceof Long) %7B%0A            writeLong((Long) o);%0A        %7D%0A        else if (o instanceof Integer) %7B%0A            writeLong(((Integer) o).longValue());%0A        %7D%0A        // Do not support smaller types, at least not for now%0A        else if (o instanceof List) %7B%0A            writeList((List%3CObject%3E) o);%0A        %7D%0A        else if (o instanceof Map) %7B%0A            writeDict((Map%3CString,Object%3E) o);%0A        %7D%0A        else %7B%0A            String msg = String.format(%22Value must either be integer, string, list or map, was %25s%22,%0A                                       o.getClass().getName());%0A            throw new IllegalArgumentException(msg);%0A        %7D%0A    %7D%0A%7D%0A

Implement BencodeWriter