BufferedOutputStream bos = null;
try {
bos = new BufferedOutputStream(new FileOutputStream(
"D:\\myfile.txt"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入一个字符串:");
String line;
try {
line = br.readLine();
System.out.println("你输入的字符串是:" + line);
String str = line + "&";
if (line.contains("gench")) {
System.out.println("上海建桥学院");
}
bos.write(str.getBytes());
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}