import java.nio.charset.Charsets
在我的类 UriCodec.java 中,但是当我使用 javac(jdk6) 编译此类错误时。例如:javac UriCodec.java
错误代码:
import java.nio.charset.Charsets;
^
UriCodec.java:140: Can not find symbol
symbol: Variable Charsets
position: class com.android.exchange.utility.UriCodec
appendEncoded(builder, s, Charsets.UTF_8, false);
^
UriCodec.java:144: Can not find symbol
symbol: Variable Charsets
position: class com.android.exchange.utility.UriCodec
appendEncoded(builder, s, Charsets.UTF_8, true);
^
UriCodec.java:203: Can not find symbol
symbol: Variable Charsets
position: class com.android.exchange.utility.UriCodec
return decode(s, false, Charsets.UTF_8);
^
UriCodec.java:214: Can not find symbol
symbol: Method toHexString(byte,boolean)
position: class java.lang.Byte
sb.append(Byte.toHexString(b, true));
^
5 error
我的课:
import java.nio.charset.Charset;
import java.nio.charset.Charsets;
public abstract class UriCodec {
public final void appendEncoded(StringBuilder builder, String s) {
appendEncoded(builder, s, Charsets.UTF_8, false);
}
public final void appendPartiallyEncoded(StringBuilder builder, String s) {
appendEncoded(builder, s, Charsets.UTF_8, true);
}
public static String decode(String s) {
return decode(s, false, Charsets.UTF_8);
}
public final String encode(String s, Charset charset) {
// Guess a bit larger for encoded form
StringBuilder builder = new StringBuilder(s.length() + 16);
appendEncoded(builder, s, charset, false);
return builder.toString();
}
}