public byte[] toByteArray(){
		byte [] out = null;
		try {
			ByteArrayOutputStream bo = new ByteArrayOutputStream();
			OutputStream baos = bo;
			if(this.type==Type.Dictionary){
				baos.write('d');
				for(Entry<String, Bencoding> s:dictionary.entrySet()){
					byte [] bytes = s.getKey().getBytes("UTF-8");
					String l = Long.toString(bytes.length);
				    baos.write(l.getBytes("UTF-8"));
				    baos.write(':');
				    baos.write(bytes);
				    baos.write(s.getValue().toByteArray());
				}
				baos.write('e');
			}else if(this.type==Type.Integer){
				baos.write('i');
				String s = integer.toString();
			    baos.write(s.getBytes("UTF-8"));
				baos.write('e');
			}else if(this.type==Type.List){
				baos.write('l');
				for(Bencoding b: list){
					baos.write(b.toByteArray());
				}
				baos.write('e');
			}else{
				byte [] bytes = byteString;
				String l = Long.toString(bytes.length);
			    baos.write(l.getBytes("UTF-8"));
			    baos.write(':');
			    baos.write(bytes);
			}
		
			baos.close();
			baos.flush();
			out = bo.toByteArray();

		} catch (IOException e) {
			e.printStackTrace();
		}
		return out;
	}