尝试使用eclipse在java中编写希腊词

时间:2017-12-10 20:38:54

标签: java eclipse

我想要做的是希腊拼写程序的一部分。我不会深入了解关于类等的信息。但我目前正在研究一个要求用户输入希腊文本的类,但它无法理解希腊字母和打印随机的东西,如“╬β -'╧Γ╬β-'”甚至我已将设置更改为utf-8,在Window-Preferences- General-Workspace-文本文件编码设置为utf-8和来自Project-Propertied-Resource-其他(UTF-8)

public static void main(String[]args) {



    try {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in,"cp737"));
        String str = "";


        str = in.readLine();
        // Create the encoder and decoder for ISO-8859-7
        Charset charset = Charset.forName("cp737");
        CharsetDecoder decoder = charset.newDecoder();
        CharsetEncoder encoder = charset.newEncoder();

        // Convert a string to ISO-LATIN-7 bytes in a ByteBuffer
        // The new ByteBuffer is ready to be read.
        ByteBuffer bbuf = encoder.encode(CharBuffer.wrap(str));

        // Convert ISO-LATIN-7 bytes in a ByteBuffer to a character ByteBuffer and then to a string
        // The new ByteBuffer is ready to be read.
        CharBuffer cbuf = decoder.decode(bbuf);
        String s = cbuf.toString();
        System.out.println(new String(s.getBytes(),"Cp1253"));


        } catch (IOException e) {

            e.printStackTrace();
            }

    }   

0 个答案:

没有答案