0
打印出當我打印出的問題[0]到一個TextArea,輸出看起來像這樣:字符串數組(字符串[])是在單個線儘管的println
Line1Line2
我所要的輸出看起來像這樣:
一號線
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();
}
}
這看起來像是客戶端的問題。您應該顯示接收方。如果文本顯示爲HTML,則在每行後面添加'
', – Axel
'questionsList'中的strs是否帶有帶'/'符號的文本? –
@Axel:OP說這是輸出到'textarea';如果是這樣,換行符就足夠了。使用'
'實際上會將文本'
'放在'textarea'中。 –