如何将输入窗口的内容以文本形式保存到本地

allen0311 2005-01-05 10:41:41
import java.util.HashSet;
public class SupportSystem{
private InputReader reader;
/**
* Creates a technical support system.
*/ public SupportSystem() {
reader = new InputReader(); }
/**
* Start the technical support system. This will print a welcome message and enter
* into a dialog with the user, until the user ends the dialog.
*/
public void start() {
boolean finished = false;
printWelcome();
while(!finished)
{
HashSet input = reader.getInput();
if(input.contains("bye"))
{
finished = true;
}
else
{
System.out.println("response");
}
}
printGoodbye();
}

/**
* Print a welcome message to the screen.
*/

private void printWelcome()
{
System.out.println("Welcome to the DodgySoft Technical SupportSystem.");
System.out.println();
System.out.println("Please tell us about your problem.");
System.out.println("We will assist you with any problem you might have."); System.out.println("Please type 'bye' to exit our system.");
}

/**
* Print a good-bye message to the screen.
*/

private void printGoodbye()
{
System.out.println("Nice talking to you. Bye...");
}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Arrays;

public class InputReader
{
private BufferedReader reader;
/**
* Create a new InputReader that reads text from the text terminal.
*/

public InputReader()
{ reader = new BufferedReader(new InputStreamReader(System.in));; }

/**
* Read a line of text from standard input (the text
* terminal), and return it as a set of words.
*
* @return A set of Strings, where each String is one of the
* words typed by the user
*/
public HashSet getInput()

{ System.out.print("> "); // print prompt
String inputLine = readInputLine().trim().toLowerCase();
String[] wordArray = inputLine.split(" "); // split at spaces
// add words from array into hashset
HashSet words = new HashSet();
for(int i=0; i < wordArray.length; i++)
{ words.add(wordArray[i]);
}
return words;
}


/**
* Read one line of input and return it as a String.
*
* @return A String representing the input, or an empty String
* if an error occurs.
*/

private String readInputLine()
{ String line = "";
try { line = reader.readLine();
}
catch(java.io.IOException exc)
{ System.out.println ("Read error: " + exc.getMessage());
}
return line;
}
}


请问 在执行了 class SupportSystem 里面的method start 以后, 怎么把输入的对话用
filewriter 存入文本啊

我知道可以这样
BufferedWriter bufOut=new BufferedWriter(new FileWriter(FilePath));
bufOut.write("your Strings");
bufOut.flush();

但是如何从对话中把"your Strings"的值获取出来
...全文
117 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
allen0311 2005-01-06
  • 打赏
  • 举报
回复
如何定义啊 具体点啊~
allen0311 2005-01-06
  • 打赏
  • 举报
回复
如何定义啊 具体点啊~
御南 2005-01-05
  • 打赏
  • 举报
回复
定义你的getXXX()方法

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧