gpt4 book ai didi

java - 来自 JTextField 的波兰语字母

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:50:53 25 4
gpt4 key购买 nike

如何从 JTextFieldJTextArea 获取带有波兰字母的 String?当我使用 myTxtArea.getText() 并且在我的 JTextArea 中时,我得到了 ĄĆĘŁŃÓŚŹŻąćęłńóśźż 它只识别 ?????Ó ????????ó???

来自 JTextFieldJTextArea 的文本将保存在 *.txt 文件中

这是我的代码:

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MyAppCreateAcc {

public static void main(String[] args) throws IOException {
AppGUI ag = new AppGUI();
}
public MyAppCreateAcc() throws IOException {

String group = AppGUI.getGroup().getText();

String[] lines = AppGUI.getNote().getText().split("\\n");

BufferedWriter w = new BufferedWriter(new FileWriter(
"zaloz_konta.cmd"));
w.write("mode con codepage select=1250");
w.newLine();

for (int j = 0; j < lines.length; j++) {

/*
* delete more than one space between words and from the full name
* create a short one first letter of name and surname after all
* lowercase like on example: John Smith = jsmith
*/
if (lines[j] == null || lines[j].equals("")) {

// if there is a gap between the names do nothing

} else {
lines[j] = lines[j].trim().replaceAll(" +", " ");
Pattern pattern = Pattern.compile("\\s([A-Za-z]+)");
Matcher matcher = pattern.matcher(lines[j]);
String shortName = "";
if (matcher.find()) {
shortName = (lines[j].charAt(0) + matcher.group(1))
.toLowerCase();
}

w.write("call konto.cmd " + shortName + " \"" + lines[j]
+ "\" 123 " + "\"" + group + "\"");
w.newLine();
}
}
w.close();
}

}

我只想从以下位置获取波兰语字母:

String[] lines = AppGUI.getNote().getText().split("\\n");

最佳答案

JTextCompoents使用

默认接受分隔符和文件编码页面

关于java - 来自 JTextField 的波兰语字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15246638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com