public static String urlEncode (byte [] array) {
		int size = array.length-1;
		byte [] out = new byte[size*3+2];
		int cout=0;
		size=0;
		while (size<array.length) {
			if (Character.isDigit(array[size])|| Character.isAlphabetic(array[size]) || array[size] == '-' ||array[size] == '_' || array[size] == '.' || array[size] == '~'){ 
				out[cout++] = array[size];
			}else{
				out[cout++] = '%';
				out[cout++] = (byte) to_hex((byte) (array[size] >> 4));
				out[cout++] = (byte) to_hex((byte) (array[size] & 15));
			}
			size++;
		}
		out[cout++]='\0';
		String s = null;
		try {
			s = new String(out,"UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return s.trim();
	}