键盘录入一段英文, 将每个英文中的单词反序 , 最后将反序后的英文 写入项目下 c.txt中
例如 录入 : wo ai ni 在c.txt保存 ow ia in
________________________________________________________________________________________
System.out.println("请输入xx xx xx格式的字符串");
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
String[] split = s.split(" ");
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("c.txt"));
for (int i = 0; i < split.length; i++) {
StringBuilder sb = new StringBuilder(split[i]);
StringBuilder rev = sb.reverse();
String s1 = rev.toString();
bos.write((s1+" ").getBytes());
}
bos.close(); |
|