The example of this article tells the method of changing file query by Java. Share it for everyone for your reference. The specifics are as follows:
When you often publish a package, you need to find the data file updated after the package was issued last time, so I wrote this publishing package.
Copy the command of the output, execute under the DOS window,
Why not copy the file directly, because the Java copy file will modify the final modification date, so copy the copy under the DOS.
/*** The file template generated by the change is* window> Preferred> Java> code generation> code and annotation*/package com.cn.wangk.tools; Import java.Awt.Borderlayout; Import java.Color; Import java.awt.comPonent; Import Java.awt.Container; Import java.awt.flowlayout; Import java.gridlayout; Import java.awt.ACTINT.ACTINT. Ort java.awt.event.actionListener; Import java.util. Calendar; Import Java.util.gregorianCalendar; Import javax.swing.borderFactory; Import javax.swing.jbutton; Import javax.swing.jcombobox; Import x.swing.jframe; Import javax.swing.jpanel;/***// ** * bean to display a month carear in a jpanel. Only works for the authorn * carendar. * * @Author Ian f. darwin, http://www.darwinsys.com/ * @Version $ id: Cal.j ava, v 1.5 2004/02/09 03:33:45 Ian Exp $*/Public Class Cal Extends Jpanel {/***// ** The CurrenTly-InterestIn (Not Modulo 1900!)*/ProteCted Int; /* **// ** CurrenTly-Interesting Month and Day*/Protected Int MM, DD;/***// ** The Buttons to be displayed*/Protected jbutton labs [] [];/******* //** *The Number of Day Squares to Leave Blank at the Start of This Month*/Protected Int Leadgap = 0;/***// ** A Calendar Object using this*/Calen dar carendar = new gregorianCalendar (); /*** // ** Today's year*/ProteCted Final Int Thisyear = Calendar.Get (Calendar.year);/***// ** TODAY's Month*/Protected Final = CAL endar.get (Calendar.month); /* **// ** One of the Buttons. We just keep its reference for getbackGround ().*/Private jbutton B0;/** ** the Month Choice*/Private Jcombobox MON ThChoice;/***// ** The year choice*/private jcombobox year years;/***// ***construment a call, starting with today.*/Call () {super (); (Calendar.year), Calendar .get (Calendar.mand), Calendar.get (Calendar.Day_of_month); Buildgui (); Recompute ();}/*** *** *** ** *** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** lead aid E Total Days * * @Exception iLlegalargumentexception * if year out of range */ call (int Year, int Month, int today) {super (); Setyymmdd (Year, Month, TODAY); buildgu I (); Recompute ();} Private void Setyymmdd (int Year, int Month, int Today) {yy = year; mm = month; dd = today;} string [] months = {"january", "february", "march", "april", "may", "june", "june" "," July "," August "," SEPTEMBER "," October "," November "," December "};/***// ** build the gui. Assumes that setymmddddddd. OID Buildgui () {getAccessibleContext (). Setaccessiblescription ("Calendar Not Accessible Yet. Sorry!"); );; new borderlayout ()); jpanel tp = new jpanel (); tp.add ( monthChoice = new jcombobox ()); for (int i = 0; i <months.length; i ++) monthchoice.addIntem (months [i]); ]); ) {Public Void ActionPerformed (ActionEvent AE) {int i = MonthChoice.getSelectindex (); if (i> = 0) {mm = i; // System.out.println ("month =" + mm ); Recompute () ;}}}); ("Choose a Month of the year"); tp.add (yearchoice = new jcombobox ()); Yearchoice .Seteditable (true); for (int i = yy -5; i <yy+5; i ++) year ofarchoice.addIntem raing (yy); Yearchoice.AdDactionListener (New ActionListener () {Public Void ActionPerformed (ActionEvent Ae) {int i = yearchoice.getSelectEdindex (); if (i> = 0) {yy = Choice.getSelectEdItem () .tring ()); // System.out.println ("Year =" + YY); Recompute ();}}); add (borderlayout.center, tp); jpanel bp = new jpanel (); (7, 7 ); Labs = new jbutton [6] [7]; // first row is days bp.add (b0 = new jbutton ("s"); bp.add (new jbutton ("m")); bp. add (new jbutton ("t"); bp.add (new jbutton ("w"); bp.add (new jbutton ("r"); bp.add (new jbutton ("f")); bp.add (new jbutton ("s"); ActionListener DateSetter = New ActionListener () {Public Void ActionPerFormed (ActionEvent E) {String Num = E.GetaCTionCommand () ; if (! Num.equals ("") {{ // Set The Current Day Highlight SetDayActive (Integer.parseint (Num)); // When this becomes a bean, you can ///// fire some kind of datechanged high. // ALS O, Build a SimiLAR DAYSETER for Day-OF- Week btns.}}; // Construction all the buttons, and add them. for (int i = 0; i <6; i ++) for (int j = 0; j ++) {bp.add (labs [i] [j] = new jbutton (""); Labs [i] [j] .adDactionListener (dateSetter);} add (borderLayout.south, BP); 28, 31, 30,/** //*Jan Feb Mar APR*/31, 30, 31, 31, 31, 31,/** //*May Jul Aug*/30, 31, 30, 31/** // *SEP Oct Nov DEC*/};/***// ** Compute which days to put where, in the cal Panel*/Protected void Recompute () {// System.out.println ("CAL :: REC ompute: " + yy +": " + mm +": " + dd); if (mm <0 || mm> 11) Throw New Illegalargumentexception (" Month " + MM +" Bad, Must be 0-11 "); (); Calendar = New GregorianCalendar (YY, MM, DD); // Compute How much to leave before the first. // getday () Returns 0 for sunday. p = new gregorianCalendar (yy, mm, 1) .get (Calendar.Day_of_week) - 1; // System.out.println ("Leadgap =" + Leadgap); int daysinmonth = Dom [mm]; IF (IsleENDAR.Getar.year )) && mm> 1) ++ Dayinmonth; // Blank Out the Labels Before 1st Day of Month for (Int I = 0; I <Leadgap; I ++) {Labs [0] [i] .settext ("");} // File in number for the day of month. For (int i = 1; i <= daysinmonth; i ++) {jbutton b = labs [(Leadgap + I -1) / 7] [(Leadgap + I -1) %] ; B.SetText (Integer.Tostring (I));} // 7 days/week * up to 6 rows for (int i = leadgap + 1 + daysinmonth; i <6 * 7; i ++) {(i) [(i) / 7] [(i) % 7] .setText ("");} // shadeurrent day, only if curren month if (thisyear == yy && mm == ThiSmonth) setdayactive (dd); // shade the box For today // say we need to be drawn on the screen repaint ();}/** * // ** * isleap () Return true if the given year is a leap year. AR If it is divisible by 4 but not by 100, Except * that year divisible by 400 * are * leap year. */ Public Boolean Isleap (int Year) { ifar % 4 == 0 && Year % 100! = 0 || Year % 400 == 0) Return True; Return false;}/***// ** set the year, month, and day*/public void setdate (int yy, int mm, int dd) {// system.out.println ("call :: setdate"); this.yy = yy; this.mm = mm; // starts at 0, like date this .dd = dd; recompute ();}/***// ** unset any previously highlight day*/prive void clearActive () {jbutton b; // first un-size thes viously-selected square, if any if (if any if ActiveDay> 0) {b = labs [(Leadgap + ActiveDay -1) / 7] [Leadgap + ActiveDay -1) %]; ctiveDay = -1;}} Private int ActiveDay = -1;/***// ** set just the day, on the current month*/public void setdayactive (int newday) {cleardayActive (). ; // set the new one if (newDay <= 0) dd = new gregorianCalendar (). Get (calendar.day_of_month); else dd = newday; // Now shade the correct swonent square = labs [(leadgap + NewDay -1) / 7] [Leadgap + newDay -1) % 7]; Square.setbackGround (color.red); square.repaint (); activeday = newday;}/** ** for testing, a map program*/place stat IC VOID Main ( String [] av) {jframe f = new jframe ("call"); Container C = F.GetContentPane (); C.SetLayout (New FlowLayout ()); // for this test driver, HardCode 1995/0 2/10. C.ADD (New Cal (1995, 2-1, 10)); // and BeSide it, the Current Month. C.add (new call ()); f.setvisible (true); }}
It is hoped that this article is helpful to everyone's Java program design.