URLEncoder.encode() method uses the platform default character encoder to create a byte array to be URL encoded. This fails when the default character encoder is not ASCII compatible.
Comments
SUGGESTED FIX
Change call to OutputStreamWriter as per example:
public static String encode(String s) {
int maxBytesPerChar = 10;
ByteArrayOutputStream out = new ByteArrayOutputStream(s.length());
ByteArrayOutputStream buf = new ByteArrayOutputStream(maxBytesPerChar);
OutputStreamWriter writer = new OutputStreamWriter(buf,"ISO8859_1");
// method continues
11-06-2004
EVALUATION
This is a duplicate of 4041072.
benjamin.renaud@Eng 1997-08-29