Xiaobo Sun

          Eclipse-Unix http://umlfact.berlios.de/~s_xsun/

          #find ./ -type f -name "*.swp"|xargs rm -rf #find . -name "*.cpp" -exec grep "SoapEvMessage" \; -print

           #find ... -exec rm {} \;
           #find ... | xargs rm -rf

          兩者都可以把find命令查找到的結果刪除,其區別簡單的說是前者是把find發現的結果一次性傳給exec選項,這樣當文件數量較多的時候,就 可能會出現“參數太多”之類的錯誤,相比較而言,后者就可以避免這個錯誤,因為xargs命令會分批次的處理結果。這樣看來,“find ... | xargs rm -rf”是更通用的方法,推薦使用!

          rm不接受標準輸入,所以不能用find / -name "tmpfile" |rm

          -exec   必須由一個   ;   結束,而因為通常   shell   都會對   ;   進行處理,所以用   \;   防止這種情況。  
            {}   可能需要寫做   '{}',也是為了避免被   shell   過濾

          find ./ -type f -exec grep iceskysl {} /dev/null \;
          ./表示從當前目錄找
          -type f,表示只找file,文件類型的,目錄和其他字節啥的不要
          -exec 把find到的文件名作為參數傳遞給后面的命令行,代替{}的部分
          -exec后便跟的命令行,必須用“ \;”結束

          #find ./ -type f -name "*.cpp"|xargs grep "test" -n
          #find . -name "*cpp" -exec grep "test" {} \; -print

          posted @ 2008-07-29 14:27 Xiaobo Sun 閱讀(3061) | 評論 (0)編輯 收藏

          Vim cut, copy and paste

          posted @ 2008-07-11 08:53 Xiaobo Sun 閱讀(366) | 評論 (0)編輯 收藏

          GridLayout

          Each SWT widget has a (possible) containing area as known as the cell.

          horizontalAlignment, verticalAlignment is used to set the widget position
          grabExcessHorizontalSpace, grabExcessVerticalSpace is used to set the cell.

          posted @ 2008-06-26 11:22 Xiaobo Sun 閱讀(273) | 評論 (0)編輯 收藏

          View the Listening port under linux: #netstat -nl | grep 3141

          netstat -nl | grep 3141

          =========================

          nmap -sT -O localhost

          cat /etc/services | grep 3141

          netstat -anp | grep 3141

          lsof -i | grep 3141

          posted @ 2008-06-18 08:48 Xiaobo Sun 閱讀(334) | 評論 (0)編輯 收藏

          LD_LIBRARY_PATH

          vim /etc/ld.so.conf
          ====================
          LD_LIBRARY_PATH: defines the path of dynamic libraries used at the run time
          LD_RUN_PATH: at compile time tells the exe file what is path of dynamic libraries used at the run time
          ======================
          ldd exe // show the used dynamic libs

          posted @ 2008-06-16 13:21 Xiaobo Sun 閱讀(413) | 評論 (0)編輯 收藏

          Linux cmd : #du -k, #uname -r,# >> 2> , #tail -f, #tar -xzvf

           Dir size
           du -k (kilo byte)
           linux kernel  version
           uname -r
           umlenkung
           >> , 2>
             ps -aux | grep "lct*"
             tar -xvf foo.tar, tar -xzvf foo.tar
           refresh  tail -f /var/log/messages


          posted @ 2008-06-15 13:46 Xiaobo Sun 閱讀(314) | 評論 (0)編輯 收藏

          mysql.exe -u root -p

          mysql.exe -u root -p

          posted @ 2008-06-08 12:19 Xiaobo Sun 閱讀(333) | 評論 (0)編輯 收藏

          JSP Scope

          There are 4 scopes application, session, request and page in the order of thier significance. 
           
          Application represent the ServletContext. The scope is accesible throught out the application. 
           
          session represents HTTPSession object. This is valid till the user requests the application. 
           
          Request represent the HTTPServletRequest and valdi to a particular request. A request may span a single JSP page or multiple depending upon teh situations. 
           
          Page is the least valid scope. It is valid to the particular JSP page only This is some thing like private variable 

          posted @ 2008-06-03 16:01 Xiaobo Sun 閱讀(372) | 評論 (0)編輯 收藏

          wget : #wget -r -np -nd http://example.com/packages/

          1. $ wget -r -np -nd http://example.com/packages/

            這條命令可以下載 http://example.com 網站上 packages 目錄中的所有文件。其中,-np 的作用是不遍歷父目錄,-nd 表示不在本機重新創建目錄結構。

          2. $ wget -r -np -nd --accept=iso http://example.com/centos-5/i386/

            與上一條命令相似,但多加了一個 --accept=iso 選項,這指示 wget 僅下載 i386 目錄中所有擴展名為 iso 的文件。你也可以指定多個擴展名,只需用逗號分隔即可。

          3. $ wget -i filename.txt

            此命令常用于批量下載的情形,把所有需要下載文件的地址放到 filename.txt 中,然后 wget 就會自動為你下載所有文件了。

          4. $ wget -c http://example.com/really-big-file.iso

            這里所指定的 -c 選項的作用為斷點續傳。

          5. $ wget -m -k (-H) http://www.example.com/

            該命令可用來鏡像一個網站,wget 將對鏈接進行轉換。如果網站中的圖像是放在另外的站點,那么可以使用 -H 選項。

          posted @ 2008-06-02 17:28 Xiaobo Sun 閱讀(680) | 評論 (0)編輯 收藏

          Java Stream

          stream應該是水龍頭里的水資源,
          InputStream:是一個出水龍頭(把水封裝在里頭)的一個實物對象,該對象的read方法呢,就想成這
          個"出水龍頭"這一機制對象的開關鈕,你read或openStream(其他對象包容InputStream對象的對象方法)
          一下呢,就等于打開了出水龍頭的按鈕,水就出來了,里頭封裝的水是什么性質的呢,
          你就用相應的容器來裝,如string或byte[].....
          OutputStream:你就在InputStream基礎上反著想就ok了
          =====================================================================================
          當然,我們可以在Inputstream和OutputStream數據源的基礎上,從實際需要觸發,
                來重新封裝出不同性能機制的輸入、輸出流了,java.io包中提供了很豐富的輸入、輸出流對象,如:
               基于字節流的stream:
                DataOutputStream----DataInputStream:
                   FileOutputStream-----FileInputStream:
          File->inputstream->...
          ...->outputstream->File

                  .............等,可以用InputStream和OutputStream從JDK文檔查閱
               基于字符流的stream(典型的以write 和reader來標識的):
                FileWriter---FileReader:
                   StringWriter---StringReader:
                    .........等,你自己可以用Writer和Reader從JDK文檔里頭查看說明
          ======================================================================================

          InputStreamReader r = new InputStreamReader(System. in ); // InputStream from console
          BufferedReader in = new BufferedReader ( r );
          String line ;
          while (( line = in . readLine ()) != null) {
            System. out . println ( "> "+line );
          }

          FileReader r = new FileReader ( args [0]); // InputStream from file
          BufferedReader in = new BufferedReader ( r );
          String line ;
          while (( line = in . readLine ()) != null) {
            System. out . println ( "> "+line );
          }

          FileWriter w = new FileWriter ( args [0]); //OutputStream to file
          BufferedWriter bw = new BufferedWriter (w);
          PrintWriter out = new PrintWriter (bw);
          out . println ( "dies" );
          out . println ( " ... ist ein Log!" );
          out . println ( "Ciao!" );
          out . close (); // schliessen nicht vergessen !
          ===================================================================
          FileInputStream是InputStream的子類,由名稱上就可以知道, FileInputStream主要就是從指定的File中讀取資料至目的地。

          FileOutputStream是OutputStream的子類,顧名思義,FileOutputStream主要就是從來源地寫入資料至指定的File中。

          標準輸入輸出串流物件在程式一開始就會開啟,但只有當您建立一個FileInputStream或FileOutputStream的實例時,實際的串流才會開啟,而不使用串流時,也必須自行關閉串流,以釋放與串流相依的系統資源。

          下面這個程式可以復制檔案,程式先從來源檔案讀取資料至一個位元緩沖區中,然后再將位元陣列的資料寫入目的檔案:

          • FileStreamDemo.java
          package onlyfun.caterpillar;

          import java.io.*;

          public class FileStreamDemo {
          public static void main(String[] args) {
          try {
          byte[] buffer = new byte[1024];

          FileInputStream fileInputStream =
          new FileInputStream(new File(args[0]));
          FileOutputStream fileOutputStream =
          new FileOutputStream(new File(args[1]));

          System.out.println("復制檔案:" +
          fileInputStream.available() + "位元組");
          while(true) { // 從來源檔案讀取資料至緩沖區
          if(fileInputStream.available() < 1024) {
          int remain;
          while((remain = fileInputStream.read())
          != -1) {
          fileOutputStream.write(remain);
          }
          break;
          }
          else {
          fileInputStream.read(buffer);
          // 將陣列資料寫入目的檔案
          fileOutputStream.write(buffer);
          }
          }

          // 關閉串流
          fileInputStream.close();
          fileOutputStream.close();

          System.out.println("復制完成");
          }
          catch(ArrayIndexOutOfBoundsException e) {
          System.out.println(
          "using: java FileStreamDemo src des");
          e.printStackTrace();
          }
          catch(IOException e) {
          e.printStackTrace();
          }
          }
          }

          這個程式示范了兩個 read() 方法,一個可以讀入指定長度的資料至陣列,一個一次可以讀入一個位元組,每次讀取之后,讀取的指標都會往前進,您使用available()方法獲得還有多少位元組可以讀取;除了使用File來建立FileInputStream、FileOutputStream的實例之外,您也可以直接使用字串指定路徑來建立。

          不使用串流時,記得使用close()方法自行關閉串流,以釋放與串流相依的系統資源。

          posted @ 2008-05-19 15:21 Xiaobo Sun 閱讀(958) | 評論 (1)編輯 收藏

          僅列出標題
          共7頁: 上一頁 1 2 3 4 5 6 7 下一頁 
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          導航

          統計

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 辽宁省| 江川县| 永吉县| 射洪县| 吉木乃县| 鹿邑县| 绥中县| 资中县| 商南县| 峡江县| 巫山县| 务川| 陇南市| 玉龙| 凤凰县| 长葛市| 星子县| 南城县| 静安区| 泰顺县| 张北县| 本溪| 济源市| 渑池县| 琼中| 宜城市| 青州市| 堆龙德庆县| 昔阳县| 双牌县| 江西省| 天柱县| 柳林县| 耒阳市| 娄烦县| 吕梁市| 松原市| 合肥市| 南丰县| 萝北县| 东阳市|