[Java] 纯文本查看 复制代码
public class Demo {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
String line = sc.nextLine();
fun(Integer.parseInt(line));
}
public static void fun(int i) throws Exception {
FileOutputStream fos = new FileOutputStream("a.txt");
String[] arr = { "", "壹", "贰", "叁" };
String s = i + "";
for (int j = 0; j < s.length(); j++) {
int ii = Integer.parseInt(s.charAt(j) + "");
if (ii < 1 || ii > 3) {
System.out.println("找不到对应的汉字");
return;
}
String ss = arr[ii] + " ";
fos.write(ss.getBytes());
System.out.print(ss);
}
fos.close();
}
}