Percent Encode the provided byte. @param data to encode @param bos with the output stream to use.
(byte data, ByteArrayOutputStream bos)
| 177 | * @param bos with the output stream to use. |
| 178 | */ |
| 179 | private static void pctEncode(byte data, ByteArrayOutputStream bos) { |
| 180 | bos.write('%'); |
| 181 | char hex1 = Character.toUpperCase(Character.forDigit((data >> 4) & 0xF, 16)); |
| 182 | char hex2 = Character.toUpperCase(Character.forDigit(data & 0xF, 16)); |
| 183 | bos.write(hex1); |
| 184 | bos.write(hex2); |
| 185 | } |
| 186 | |
| 187 | private static boolean isAlpha(int c) { |
| 188 | return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'); |