public class AbsenteeNote {
public static void main(String[] args) throws IOException {
int select = 0;
select = welcome();
if (select == 1 || select == 2) {
writeLetter(select);
} else {
viewLetter();
}
}
private static int welcome() {
int num = 0;//用于第一层菜单的选择
int num1 = 0;//用于第二层菜单的选择
do {
System.out.println("1:编写请假条");
System.out.println("2:查看请假条");
System.out.print("请选择功能号:");
Scanner in = new Scanner(System.in);
num = in.nextInt();
} while (num != 1 && num != 2);//若输出的数字不为1或2,则继续选择
if (num == 1) {
do {
System.out.println("1:病假");
System.out.println("2:事假");
System.out.print("请选择功能号:");
Scanner in = new Scanner(System.in);
num1 = in.nextInt();
} while (num1 != 1 && num1 != 2);
return num1;
} else {//当输入的是2(查看请假条),则任意返回一个值。
return 0;
}
}
private static void viewLetter() {//查看请假条
File letter = new File("c:\\Letter\\Letter.txt");
try {
FileInputStream view = new FileInputStream(letter);
byte b[] = new byte[view.available()];