从键盘输入一个字符串,将其中的小写字母全部转换成大写字母,然后输出到一个磁盘文件"test.txt"中保存。输入的字符串以"!"结束。
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;
public class Test {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Test test=new Test();
test.reSet();
}
public void reSet() throws IOException {
Scanner input = new Scanner(System.in);
System.out.println("输入一个字符串");
String str = input.next();
byte[] by = str.toUpperCase().concat("!").getBytes();
File f = new File("c:/Users/admin/Desktop/test.txt");
FileOutputStream fo = new FileOutputStream(f);
fo.write(by);
fo.close();
}
}
对输入字符串进行一系列操作之后 利用IO写入记事本 纯手打 望采纳