我寫了一個程序,允許用戶在一個文件中存儲多個備忘錄。我想出瞭如何在Java中使用PrintWriter &文件,但是我的問題與我的輸出有關。當我在記事本中檢查文件時,我只能輸入一個備忘錄,沒有問題&,只有一個備忘錄存在。下面的代碼: import java.util.*;
import java.io.*;
public class MemoPadCreator{
public
我想使用out.print將字符串打印到文本,但字符串中的\n不起作用。 下面是代碼: import java.io.PrintWriter;
public class LetterRevisited{
public static void main(String[] args)throws Exception
{
PrintWriter out = new P
我有一個方法(PrintTree),它返回一個字符串(treeString),有多行。該字符串看起來像這樣: html
head
link
body
當我將它打印到控制檯時,它正確地打印字符串。但是,當我嘗試使用printWriter時,它不輸出任何內容。 PrintWriter out=new PrintWriter(filePath);
out.write(PrintTree(ro
以下方法始終創建在每次打印後的新PrintWriter: public class ConsoleInput implements Runnable {
@Override
public void run() {
Scanner scan = new Scanner(System.in);
while (true) {
String msg