プログラムの実行回数を検証するウィジェット

1611 ワード

package com.lxq;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/*
 * 	                ,    :
	1.       3      :         3 ,            ~
	2.        :
		          :        , 1     ~
		          :        , 2     ~
		          :        , 3     ~
		             :         3 ,            ~
		
	  :
		           ? num.txt   , 1,2,3      >3    ,                 
		          ? IO       
		         (      )? Integer.praseInt(String)
		                  ? if  
 */
public class Test1 {
	public static void main(String[] args) throws IOException {
		//    num.txt  (  )
		//            num.txt      
		BufferedReader br = new BufferedReader(new FileReader("num.txt"));
		//      
		String line;
		//        
		int count = 0;
		//      
		if ((line = br.readLine()) != null) {
			//1,2,3
			// line       int    
			count = Integer.parseInt(line);
			//     1,2,3
			if (count == 1||count == 2) {
				//       ,        
				count++;
				//            num.txt
				BufferedWriter bw = new BufferedWriter(new FileWriter("num.txt"));
				bw.write(count + "");
				System.out.println("       , "+count+"     ~");
				bw.close();
			}else {
				System.out.println("         3 ,            ~");
			}
			
		}else {
			//  num.txt                     
			//     
			BufferedWriter bw = new BufferedWriter(new FileWriter("num.txt"));
			bw.write("1");
			System.out.println("       , 1     ~");
			bw.close();
		}
		br.close();
	}
}