I want to encode string in Java with Microsoft Windows Codepage 1251 (Cy开发者_运维问答rl) table.
You don't have to "encode" a string. When you turn a string from/to bytes you need to decode/encode them. So you actually encode a binary array.
byte[] cp1251encodedBytes = "your characters".getBytes(Charset.forName("Cp1251"));
List of supported encodings: http://download.oracle.com/javase/1.4.2/docs/guide/intl/encoding.doc.html
Update: updated to Charset.forName() as McDowell commented.
精彩评论