0

バイトが入力されたテキスト フィールドがあります。String s = textfield.getText(); を呼び出すと、デフォルトでは、返されるバイトの文字列データ型です。テキストフィールドの実際のバイトをデータ型バイトとして取得したい。しかし、s.getbyte を実行すると、バイトが新しいバイトに変換されます。ここで私を助けてくれる人をお願いします。

           //this gives me another bye than the one in the text field.
            String ss = new String(Textfield().getText().getBytes(), "UTF-8");

            //i want to get something like this
            byte [] b = Textfield().getText(); //without geting a new byte
            String ss = new String(Textfield().getText().getBytes(), "UTF-8");
4

1 に答える 1

-1

呼び出すだけでString#getBytes()、常にString#intern()コンストラクターの後に呼び出して、新しい文字列を Stringpool に入力します。

byte [] b = Textfield().getText().getBytes();
String ss = new String(Textfield().getText().getBytes(), "UTF-8").intern();
于 2013-10-19T21:12:31.683 に答える