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 阅读(3049) | 评论 (0)编辑 收藏

Vim cut, copy and paste

posted @ 2008-07-11 08:53 Xiaobo Sun 阅读(359) | 评论 (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 阅读(268) | 评论 (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 阅读(324) | 评论 (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 阅读(393) | 评论 (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 阅读(306) | 评论 (0)编辑 收藏

mysql.exe -u root -p

mysql.exe -u root -p

posted @ 2008-06-08 12:19 Xiaobo Sun 阅读(328) | 评论 (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 阅读(359) | 评论 (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 阅读(667) | 评论 (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 阅读(949) | 评论 (1)编辑 收藏

仅列出标题
共7页: 上一页 1 2 3 4 5 6 7 下一页 
<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

常用链接

留言簿(3)

随笔分类

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜