Java--> a program that can run only 10 times

Source: Internet
Author: User

--it feels like nothing nutritious ...

 PackageCom.dragon.java.tensoftware;ImportJava.io.BufferedReader;ImportJava.io.FileReader;ImportJava.io.FileWriter;Importjava.io.IOException;/** Write a program, the program can only--run--10 times, each time the runtime prompts the remaining number, 10 times after the prompt has expired*/ Public classTest { Public Static voidMain (string[] args)throwsIOException {bufferedreader br=NULL; FileWriter FW=NULL; Try{br=NewBufferedReader (NewFileReader ("c:/users/xy/desktop/file/java/java/dailycode/08-14/src/com/dragon/java/times.txt"));//define the input stream,            intTimes = Integer.parseint (Br.readline ());//reads a row of data into an int value            if(Times > 0) {System.out.println ("Welcome--10 hits--software, remaining use:" +Times ); FW=NewFileWriter ("c:/users/xy/desktop/file/java/java/dailycode/08-14/src/com/dragon/java/times.txt");//define the output stream,Fw.write (--times + "");//reduce the number of times by 1, write back to the file, and write the number of times back to the file as a string type}Else{System.out.println ("Software has expired"); }        } Catch(IOException e) {System.out.println (e); } finally {            Try{br.close ();            Fw.close (); } Catch(IOException e) {System.out.println (e); }        }    }}

-and really can't sit on the bed playing computer ... Good pain in the waist ...

Java--> a program that can run only 10 times

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.