当我将问题[0]打印到TextArea时,输出如下所示:
Line1Line2
我希望输出看起来像这样:
线路1
2号线
尽管使用println
如何更改输出的格式?
守则:
public void run() {
try {
write = new PrintStream(connection.getOutputStream());
//Skriva till klienten.
List<String> questionsList = new ArrayList<>();
try (Stream<String> questionsStream = Files.lines(Paths.get(quizFile))) { //Reading from text file
questionsList = questionsStream
.parallel()
.collect(Collectors.toList());
Collections.shuffle(questionsList); //Randomizing the Strings.
while (true) {
for (String string : questionsList) {
String[] questions = string.split("/");
write.println(questions[0]); //Printing out [0]."\n" does not seperate the String to seperate lines.
try {
Thread.sleep(4000); //"Sleeping" between the lines.
} catch (InterruptedException e) {
e.printStackTrace();
}
}
答案 0 :(得分:0)
您应该使用HTML,标记&#39;
进入write.println(questions[0] + "<br>");
。