Scanner scan=new Scanner(System.in);
String str=scan.next();
String Ustr=str.toUpperCase();
File f=new File("C:\Users\dsp\Desktop\test.txt");
if(!f.exists()) {
try {
f.createNewFile();
System.out.println("创建成功");
FileOutputStream sr=new FileOutputStream(f);
byte[] bytes = Ustr.getBytes();
sr.write(bytes);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else {
try {
FileOutputStream sr = new FileOutputStream(f);
byte[] bytes = Ustr.getBytes();
sr.write(bytes);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}