myjavaBlog

          工作越努力學到的越多。
          posts - 4, comments - 7, trackbacks - 0, articles - 34

          2009年7月24日

          從今天起停止更新我的博客,原因不必細說,
          博客遷至百度,地址
          http://hi.baidu.com/lzy_eagle

          posted @ 2009-07-24 09:45 java人生 閱讀(148) | 評論 (0)編輯 收藏

          2009年7月20日

               摘要: 需要修改的注冊表項  [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run]  開機自動運行程序 [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce] 開機自動運行程序 且 僅運行一次 [HKEY_LOCA...  閱讀全文

          posted @ 2009-07-20 09:38 java人生 閱讀(2252) | 評論 (0)編輯 收藏

          public class Test {

           /**
            * @param args
            */
           public static void main(String[] args) {
            String reg = "##12";

            System.out.println("++" + reg);
            String[] s = reg.split("#{1,}");
            System.out.println(s.length);
            for (int a = 0; a < s.length; a++) {
             System.out.println(s[a]);
            }
            String reg1 = "12";

            System.out.println("++" + reg1);
            String[] s1 = reg1.split("#{1,}");
            System.out.println(s1.length);
            for (int a = 0; a < s1.length; a++) {
             System.out.println(s1[a]);
            }
            String reg2 = "##";

            System.out.println("++" + reg2);
            String[] s2 = reg2.split("#{1,}");
            System.out.println(s2.length);
            for (int a = 0; a < s2.length; a++) {
             System.out.println(s2[a]);
            }
           }

          }

          posted @ 2009-07-20 09:27 java人生 閱讀(173) | 評論 (0)編輯 收藏

          /**
           * @author 李志遠
           */
          import java.util.regex.Matcher;
          import java.util.regex.Pattern;

          public class GetString {

           /**
            * @param args
            */
           public static void main(String[] args) {
            String reg = "a#bb##cc###";
            // 截取字符串
            String[] s = reg.split("#{1,}");
            for (int a = 0; a < s.length; a++) {
             System.out.println("截取字符串:" + s[a]);
            }
            // 獲得指定字符
            Pattern pattern = Pattern.compile("#{1,}");
            Matcher match = pattern.matcher(reg);
            while (match.find()) {

             String rules = match.group();
             System.out.println("指定字符:" + rules);
            }
           }

          }

           

          posted @ 2009-07-20 09:04 java人生 閱讀(862) | 評論 (0)編輯 收藏

               摘要: 自己用java做了一個類似紅蜻蜓截圖的軟件,里面要制作文件命名的模板, 如:    #aa##bb###  #為需要用指定序號替換的字符,10起始值 連續#個數小于等于起始值位數,#被起始值直接替換 連續#個數大于起始值位數時,#被起始值替換并且多出的#用0替換   1import java.util.regex.Matc...  閱讀全文

          posted @ 2009-07-20 08:50 java人生 閱讀(1484) | 評論 (0)編輯 收藏

          2009年6月16日

          Windows XP的關機是由Shutdown.exe程序來控制的,位于Windows\System32文件夾中。如果想讓Windows 2000也實現同樣的效果,可以把Shutdown.exe復制到系統目錄下。

          比如你的電腦要在22:00關機,可以選擇"開始→運行",輸入"at 22:00 Shutdown -s",這樣,到了22點電腦就會出現"系統關機"對話框,默認有30秒鐘的倒計時并提示你保存工作。如果你想以倒計時的方式關機,可以輸入"Shutdown.exe -s -t 3600",這里表示60分鐘后自動關機,"3600"代表60分鐘。
          設置好自動關機后,如果想取消的話,可以在運行中輸入"shutdown -a"。另外輸入"shutdown -i",則可以打開設置自動關機對話框,對自動關機進行設置。

          Shutdown.exe的參數,每個都具有特定的用途,執行每一個都會產生不同的效果,比如"-s"就表示關閉本地計算機,"-a"表示取消關機操作,下面列出了更多參數,大家可以在Shutdown.exe中按需使用。

          -f:強行關閉應用程序
            -m:\\計算機名:控制遠程計算機
            -i:顯示圖形用戶界面,但必須是Shutdown的第一個選項
            -l:注銷當前用戶
            -r:關機并重啟
            -t:時間:設置關機倒計時
            -c:"消息內容":輸入關機對話框中的消息內容(不能超127個字符)
          qu Windows XP的關機是由Shutdown.exe程序來控制的,位于Windows\System32文件夾中。如果想讓Windows 2000也實現同樣的效果,可以把Shutdown.exe復制到系統目錄下。

          比如你的電腦要在22:00關機,可以選擇"開始→運行",輸入"at 22:00 Shutdown -s",這樣,到了22點電腦就會出現"系統關機"對話框,默認有30秒鐘的倒計時并提示你保存工作。如果你想以倒計時的方式關機,可以輸入"Shutdown.exe -s -t 3600",這里表示60分鐘后自動關機,"3600"代表60分鐘。
          設置好自動關機后,如果想取消的話,可以在運行中輸入"shutdown -a"。另外輸入"shutdown -i",則可以打開設置自動關機對話框,對自動關機進行設置。

          Shutdown.exe的參數,每個都具有特定的用途,執行每一個都會產生不同的效果,比如"-s"就表示關閉本地計算機,"-a"表示取消關機操作,下面列出了更多參數,大家可以在Shutdown.exe中按需使用。

          -f:強行關閉應用程序
            -m:\\計算機名:控制遠程計算機
            -i:顯示圖形用戶界面,但必須是Shutdown的第一個選項
            -l:注銷當前用戶
            -r:關機并重啟
            -t:時間:設置關機倒計時
            -c:"消息內容":輸入關機對話框中的消息內容(不能超127個字符)

          posted @ 2009-06-16 10:49 java人生 閱讀(303) | 評論 (0)編輯 收藏

          2009年6月12日

          JLabel默認情況下是透明的所以直接設置背景顏色是無法顯示的。
          必須將其設置為不透明才能顯示背景。如
          label.setOpaque(true);
          label.setColor(Color.red);
          這樣就能解決無法顯示背景的問題了。

          posted @ 2009-06-12 11:06 java人生 閱讀(1636) | 評論 (0)編輯 收藏

          2009年6月9日

          由于項目中有關于java錄音的東西,所以從網上找些資料學習一下
            1import java.io.*;
            2import javax.sound.sampled.*;
            3
            4public class JDKAudioRecorder extends Thread {
            5    // 產生TargetDataLine類別的變數m_targetdataline
            6    static TargetDataLine m_targetdataline;
            7
            8    // 透過TargetDataLine介面(繼承自DataLine)與音效卡溝通 target目標
            9
           10    // 產生AudioFileFormat.Type類別的變數m_targetType Format格式
           11    static AudioFileFormat.Type m_targetType;
           12
           13    // 產生AudioInputStream類別的變數m_audioInputStream stream流
           14    static AudioInputStream m_audioInputStream;
           15
           16    static File m_outputFile;// 產生File類別的變數 m_outputFile
           17
           18    static boolean m_bRecording;// 後面需用到布林函數 True,False
           19
           20    public JDKAudioRecorder(TargetDataLine line,
           21            AudioFileFormat.Type targetType, File file) {
           22        m_targetdataline = line;
           23        m_audioInputStream = new AudioInputStream(line);
           24        m_targetType = targetType;
           25        m_outputFile = file;
           26    }

           27
           28    public static void AudioRecorder() {
           29        String Filename = "c://JDKAudioRecord.wav";
           30        File outputFile = new File(Filename);
           31
           32        // 我們一開始先在主程式裡指定聲音檔的檔名為
           33        // JDKAudioRecorder.wav
           34        // String Filename = "JDKAudioRecord.wav";
           35        // 接著指定存檔的資料夾,預設存在相同的資料夾
           36        // FileoutputFile = new File(Filename);
           37
           38        AudioFormat audioFormat = null;
           39        audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
           40                44100.0F162444100.0Ffalse);
           41
           42        // 再來設定和取得音效檔的屬性
           43        // audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
           44        // 44100.0F, 16, 2, 4, 44100.0F, false);
           45
           46        DataLine.Info info = new DataLine.Info(TargetDataLine.class,
           47                audioFormat);
           48        TargetDataLine targetDataLine = null;
           49
           50        // 然後透過TargetDataLine介面(繼承自DataLine)與音效卡溝通
           51        // DataLine.Info info = new DataLine.Info(TargetDataLine.class,
           52        // audioFormat);
           53        // 接著做例外處理,當聲音裝置出錯或其他因素導致錄音功能無法被執行時,程式將被終止
           54
           55        try {
           56            targetDataLine = (TargetDataLine) AudioSystem.getLine(info);
           57            targetDataLine.open(audioFormat);// try{ }可能發生例外的敘述
           58
           59        }
           catch (LineUnavailableException e)// catch{ }處理方法
           60
           61        {
           62            System.out.println("無法錄音,錄音失敗");
           63            e.printStackTrace();
           64            System.exit(-1);
           65        }

           66
           67        AudioFileFormat.Type targetType = AudioFileFormat.Type.AU;
           68        JDKAudioRecorder recorder = null;
           69
           70        recorder = new JDKAudioRecorder(targetDataLine, targetType, outputFile);
           71        recorder.start();
           72    }

           73
           74    public void start() {
           75        m_targetdataline.start();
           76        super.start();
           77    }

           78
           79    public static void stopRecording() {
           80        
           81        m_targetdataline.stop();
           82        m_targetdataline.close();
           83        m_bRecording = false;
           84    }

           85
           86    public void run() {
           87        try {
           88            AudioSystem.write(m_audioInputStream, m_targetType, m_outputFile);
           89            System.out.println("after write()");
           90        }
           catch (IOException e) {
           91            e.printStackTrace();
           92        }

           93    }

           94    
           95}

           96// 一切準備ok後,開始呼叫DataLine類別中的start()method即可
           97// 開始錄音,停止錄音則透過stopRecording()method
           98// public void start()
           99//{
          100//m_targetdataline.start();
          101//}
          102// public static void stopRecording()
          103//{
          104//m_targetdataline.stop();
          105//}
          106

          posted @ 2009-06-09 11:08 java人生 閱讀(1343) | 評論 (0)編輯 收藏

          2009年6月5日

          JRadioButton opt1=new JRadio("中餐");
          JRadioButton opt2=new JRadio("西餐");
          ButtonGroup group1=new Buttongroup();
          group1.add(opt1);
          group1.add(opt2);
          JFrame frame=new JFrame("菜單");
          constainer c=frame.getcontentPane();
          c.setlayout(new.Flowlayout());
          c.add(opt1);
          c.add(opt2);
          frame.setsize(300,200);
          frame.setTitle("First");
          frame.setvisible(true);

          posted @ 2009-06-05 10:47 java人生 閱讀(1293) | 評論 (0)編輯 收藏

          2009年5月31日

          開發過程中一直在用SVN做版本控制,使用Eclipse編譯文件后,classes文件中總是有.svn的文件夾,在做提交時有時會報錯,這些文件沒有什么用,而且影響build的速度。
          使用編譯時過濾選項可以使編譯時.svn不移到classess目錄中,設置方法:
          "Project->Properties->Java Build Path",右側的面板中的"Source"選項卡,展開"source folder "后會看到"Included"、"Excluded"和"Native library location:",在Excluded中加入"**/.svn/**",就可以將所有的svn文件排除在編譯路徑中了。

          posted @ 2009-05-31 17:22 java人生 閱讀(1287) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 乌拉特前旗| 从江县| 错那县| 铁岭市| 卓资县| 白山市| 峨边| 杨浦区| 祁东县| 灵台县| 肇东市| 丹阳市| 苏尼特左旗| 广安市| 城市| 太原市| 句容市| 大连市| 呼玛县| 双江| 永平县| 新余市| 抚远县| 宝坻区| 蓬溪县| 东阿县| 五寨县| 安宁市| 阜宁县| 泸水县| 德清县| 罗山县| 息烽县| 睢宁县| 涟源市| 同德县| 屏东市| 鄂托克旗| 遂溪县| 江达县| 奎屯市|