星期三, 十月 24, 2007

用java操纵文件后缀名

 import java.io.File;

 /*
  * Created on 2006-9-19
  *
  * TODO To change the template for this generated file go to
  * Window - Preferences - Java - Code Style - Code Templates
  */

 /**
  * @author public2298
  *
  * TODO To change the template for this generated type comment go to
  * Window - Preferences - Java - Code Style - Code Templates
  */
 public abstract class BaseFolder {
  private String folderPath = null;
  protected String suffix = null;
  
  public void visit(File file)
  {
   if(file.isDirectory())
   {
       if(getCondition(file))
           folderOper(file);
       else
       {
     File[] fileArray = file.listFiles();
     for(int i=0;i<fileArray.length;i++)
     {
      visit(fileArray[i]);
     }
       }
   }
   else
   {
    fileOper(file);
   }
  }
  protected void folderOper(File file){}
  
  protected void fileOper(File file){}
  protected boolean getCondition(File file){return false;}
  protected void deleteFolder(File file)
  {
   if(file.isDirectory())
   {
    File[] fileArray = file.listFiles();
    for(int i=0;i<fileArray.length;i++)
    {
     deleteFolder(fileArray[i]);
    }
    file.delete();
   }
   else
    file.delete();
  }
  //添加后缀名
  protected void addSuffix(File file)
  {
      formatSuffix();
      file.renameTo(new File(file.getAbsolutePath()+suffix));
  }
  //去掉后缀名
  protected void deleteSuffix(File file)
  {
      formatSuffix();
      String path = file.getAbsolutePath();
      if(path.endsWith(suffix))
      {
          path = path.substring(0,path.length()-suffix.length());
          file.renameTo (new File(path));
      }
  }
  //如果后缀名不含有点,就加上点.
  private void formatSuffix()
  {
      if((suffix!=null)&&(!suffix.startsWith(".")))
          suffix = "."+suffix;
  }
  protected void clean()
  {
   
  }
  
  protected void setSuffix(String suffix) {
         this.suffix = suffix;
     }
 }

 
 //工具类

 import java.io.File;

 /*
  * Created on 2006-9-27

  * Window - Preferences - Java - Code Style - Code Templates
  */

 public class FolderUtils {
     private File file;
     private BaseFolder folder;
     public FolderUtils(File file)
     {
         this.file = file;
     }
     
     public void addSuffix(String suffix)
     {
         folder = new AddFileSuffix();
         folder.setSuffix(suffix);
         folder.visit(file);     
     }
     public void deleteSuffix(String suffix)
     {
         folder = new DeleteFileSuffix();
         folder.setSuffix(suffix);
         folder.visit(file);     
     }
     public void deleteFileByPattern(String pattern)
     {
         folder = new DeleteFileByPattern(pattern);
         folder.visit (file);
     }
     public void deleteFileBySuffix(String suffix)
     {
         folder = new DeleteFileBySuffix(suffix);
         folder.visit(file);
     }
     public void deleteFodler(String pattern)
     {
         folder = new DeleteFolderByName(pattern);
         folder.visit(file);
     }
     public void renameFile(long startNumber)
     {
         folder = new RenameFileLikeNumber(startNumber);
         folder.visit(file);
     }
     public static void main(String[] args) {
         FolderUtils util = new FolderUtils(new File("d:/src/yy"));
         //util.addSuffix(".yx");
         //util.deleteSuffix(".yx");
         //util.deleteFileByPattern("yinxing.txt");
         //util.deleteFileBySuffix(".yx");
         //util.deleteFodler("yyy");
         util.renameFile(999);
     }
     

     public void setFile(File file) {
         this.file = file;
     }
 }

 //如果文件是以指定名字为后缀,就删除文件的后缀
 class DeleteFileSuffix extends BaseFolder {
     public void fileOper(File file) {
         this.deleteSuffix(file);
     }
 }
 //如果文件增加后缀
 class AddFileSuffix extends BaseFolder {
     public void fileOper(File file) {
         this.addSuffix(file);
     }
 }

 //删除文件夹名和指定名字一样的文件夹,不考虑大小写.
 class DeleteFolderByName extends BaseFolder {
     private String pattern = null;
     public DeleteFolderByName(String pattern)
     {
         this.pattern = pattern;
     }
     public void folderOper(File file)
     {
         deleteFolder(file);
     }
     public boolean getCondition(File file)
     {
         return file.getName().equalsIgnoreCase(pattern);
     }
 }
 //如果文件名包含指定pattern,就将文件删除
 class DeleteFileByPattern extends BaseFolder {
     private String pattern = null;
     public DeleteFileByPattern(String pattern)
     {
         this.pattern = pattern;
     }   
     public void fileOper(File file) {
         if(pattern==null)
             return;
         String fileName = file.getName();
         if(fileName.contains(pattern))
             file.delete ();
     }
 }
 //删除具有指定后缀名的文件
 class DeleteFileBySuffix extends BaseFolder {
     private String suffix;
     public DeleteFileBySuffix(String suffix)
     {
         this.suffix = suffix;
     }
     public void fileOper(File file) {
         String path = file.getAbsolutePath();
         if(path.endsWith(suffix))
             file.delete();
     }
 }
 //以依次增加的数字编号重命名文件
 class RenameFileLikeNumber extends BaseFolder
 {
     private final String WILDCARD = "#";  //通配符
     private String pattern = null;
     private long startNumber = 0;
     private long count = 0;
     
     public RenameFileLikeNumber(){}
     public RenameFileLikeNumber(long startNumber)
     {
         this.startNumber = startNumber;
         count = startNumber;
     }
     public RenameFileLikeNumber(long startNumber,String pattern)
     {
         this.startNumber = startNumber;
         this.pattern = pattern;
         count = startNumber;
     }
     public void fileOper(File file) {
         this.rename(file,getNameForFile());
         count++;
     }
     private String getNameForFile()
     {
         String fileName = "";
         if(pattern!=null)
         {
          int i = pattern.length();
          int j =  Long.toString(count).length();
          for(int k=j;k<i;k++)
              fileName += "0";
          fileName += count+"";
          return fileName;
         }
         else
             return count+"";
     }
 }

星期日, 十月 14, 2007

关闭开机Ctrl + Alt + Del组合键

Start→Administrative Tools→Local security policy→Local Policies→Security Options→Interactive Logon:Do not require CTRL+ALT+DEL

关闭win2003事件跟踪程序

Run --->gpedit.msc--->Administrative Templates--->System--->Display Shutdown Event tracker

星期三, 十月 10, 2007

CSV文件格式

CSV即Comma Separate Values,这种文件格式经常用来作为不同程序之间的数据交互的格式。

具体文件格式

  • 每条记录占一行
  • 以逗号为分隔符
  • 逗号前后的空格会被忽略
  • 字段中包含有逗号,该字段必须用双引号括起来
  • 字段中包含有换行符,该字段必须用双引号括起来
  • 字段前后包含有空格,该字段必须用双引号括起来
  • 字段中的双引号用两个双引号表示
  • 字段中如果有双引号,该字段必须用双引号括起来
  • 第一条记录,可以是字段名
  • The CSV File Format


     

    • Each record is one line   ...but
      A record separator may consist of a line feed (ASCII/LF=0x0A), or a carriage return and line feed pair (ASCII/CRLF=0x0D 0x0A).
      ...but: fields may contain embedded line-breaks ( see below) so a record may span more than one line.

    • Fields are separated with commas.
      Example John,Doe,120 any st.,"Anytown, WW",08123

    • Leading and trailing space-characters adjacent to comma field separators are ignored.
      So   John  ,   Doe  ,... resolves to "John" and "Doe", etc. Space characters can be spaces, or tabs.

    • Fields with embedded commas must be delimited with double-quote characters.
      In the above example. "Anytown, WW" had to be delimited in double quotes because it had an embedded comma.

    • Fields that contain double quote characters must be surounded by double-quotes, and the embedded double-quotes must each be represented by a pair of consecutive double quotes.
      So, John "Da Man" Doe would convert to "John ""Da Man""",Doe, 120 any st.,...

    • A field that contains embedded line-breaks must be surounded by double-quotes
      So:
        Field 1: Conference room 1  
        Field 2:
          John,
          Please bring the M. Mathers file for review  
          -J.L.
        Field 3: 10/18/2002
        ...

      would convert to:

        Conference room 1, "John,  
        Please bring the M. Mathers file for review  
        -J.L.
        ",10/18/2002,...

      Note that this is a single CSV record, even though it takes up more than one line in the CSV file. This works because the line breaks are embedded inside the double quotes of the field.

      Implementation note: In Excel, leading spaces between the comma used for a field sepparator and the double quote will sometimes cause fields to be read in as unquoted fields, even though the first non-space character is a double quote. To avoid this quirk, simply remove all leading spaces after the field-sepparator comma and before the double quote character in your CSV export files.

    • Fields with leading or trailing spaces must be delimited with double-quote characters.
      So to preserve the leading and trailing spaces around the last name above: John ,"   Doe   ",...

      Usage note: Some applications will insist on helping you by removing leading and trailing spaces from all fields regardless of whether the CSV used quotes to preserve them. They may also insist on removing leading zeros from all fields regardless of whether you need them. One such application is Excel. :-( For some help with this quirk, see the section below entitled Excel vs. Leading Zero & Space .

    • Fields may always be delimited with double quotes.
      The delimiters will always be discarded.

      Implementation note: When importing CSV, do not reach down a layer and try to use the quotes to impart type information to fields. Also, when exporting CSV, you may want to be defensive of apps that improperly try to do this. Though, to be honest, I have not found any examples of applications that try to do this. If you have encountered any apps that attempt to use the quotes to glean type information from CSV files (like assuming quoted fields are strings even if they are numeric), please let me know about it.

    • The first record in a CSV file may be a header record containing column (field) names
      There is no mechanism for automatically discerning if the first record is a header row, so in the general case, this will have to be provided by an outside process (such as prompting the user). The header row is encoded just like any other CSV record in accordance with the rules above. A header row for the multi-line example above, might be:
        Location, Notes, "Start Date", ...

     

    星期一, 十月 01, 2007

    安装NOTES db的ODBC驱动,errorcode 126问题

    安装NotesSQL3.02j(文件名一般为C959CEN.exe);
    运行NotesSQL Authentication List Manager,设置notes.ini跟ID文件
    进入控制面板,管理工具,ODBC DataSource Administrator。新建DSN,这时候会有125错误,大体意思指*.nsf无法读取。
    不知道中文下提示信息具体是什么。
     
    解决方法:将notes.ini所在目录(通常为:C:\Program Files\Lotus\Notes)跟dll文件所在目录(通常为:C:\NotesSQL)加到环境变量Path中。
    问题解决。

    星期一, 九月 03, 2007

    伪静态

    apahce配置 URL重写(伪静态)

    把如下内容保存为 .htaccess添加到网站的目录下:

    # RewriteEngine 模式打开

    RewriteEngine On

     

    # 修改以下语句中的 / 为你的网站目录地址,如果程序放在二级目录中,如/phpcms 请将 / 修改为 /phpcms

    RewriteBase /

     

    # Rewrite 系统规则,添加或者修改请根据其规则

    RewriteRule ^(.*)show-([0-9]+)-([0-9]+)\.html$ $1/show.jsp?itemid=$2&page=$3  

    RewriteRule ^(.*)list-([0-9]+)-([0-9]+)\.html$ $1/list.jsp?catid=$2&page=$3  

    RewriteRule ^(.*)show-([0-9]+)\.html$ $1/show.jsp?specialid=$2


    星期四, 八月 16, 2007

    js:修改对象onclick属性

     aTag[0].onclick = function(){showHide(id)};//both of Mozilla and IE
     aTag[0].setAttribute("onclick", "showHide('"+id+"')");//Mozilla
     aTag[0].setAttribute("onclick", function(){showHide(id)});//IE

    星期五, 八月 10, 2007

    iptables

    /etc/sysconfig/iptables

    快速清空表

    ALTER TABLE  tablename ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE;

    星期四, 八月 09, 2007

    生成文件树

    3.在命令提示符窗口中输入以下命令,如图2所示。

      dir d:\ >c:\filelist.txt

    小技巧:用DOS命令生成光盘文件列表

    图2 用此命令生成列表文件

      这样就在C:盘根目录下生成了一个名为"filelist.txt"的文本文件,该文件中即包含D:盘的文件夹列表。

      如果希望将D:盘中子目录中的文件和文件夹列表也全部列出来,可以在命令提示符窗口中输入以下命令。

      dir d:\ /s >c:\filelist.txt

      如果使用下面的命令,即加一个/b,则会生成一个简单的文件名列表,不包括其它信息,这种方法可能更加实用一些。

      dir d:\ /s /b >c:\filelist.txt

      生成文本文件后,就可以将该文件中的内容拷贝到Excel中以备日后查询,或者将该文件作为一个对象插入到Excel工作表中。这样以后就可以快速找到所需要的光盘了。

     

    1、命令 dir *.*/b/s > filelist.txt
    生成的文件格式:
    X:\XXX\A.XXX
    X:\XXX\B.XXX
    ...

    2、命令 dir *.*/b > filelist.txt
    生成的文件格式:
    A.XXX
    B.XXX
    ...

    3、命令 dir *.*/s > filelist.txt
    生成的文件格式:
    驱动器 X 中的卷是 ASOFT
    卷的序列号是 18A2-30C9

    X:\XXX 的目录

    2005-01-13 19:46 3,739,854 A.XXX
    2005-01-13 19:45 3,924,174 B.XXX
    ...
    170 个文件 704,193,612 字节
    0 个目录 2,889,695,232 可用字节

    4、命令 dir *.*/b > filelist.txt
    生成的文件格式:
    同3

    5、命令 tree/f > X:\tree.txt
    可以生成树形文件结构,适合做层次分明的文件结构清单,比如网站内容清单等

    星期三, 八月 08, 2007

    星期三, 八月 01, 2007

    StringUtil


    package sample;

    import java.util.StringTokenizer;
    /**

      * StringUtil
      */
    public class StringUtil {
             /**
              * 文字列の分割(区切り文字指定)
              * @param str 対象文字列
              * @param delim 区切り文字列
              * @return 分割後の文字列
              */
             public static String[] split(String str, String delim) {
                      StringTokenizer st = new StringTokenizer(str, delim);
                      int length = st.countTokens();
                      String[] result = new String[length];
                      for (int i = 0; i < length; i++) {
                          result[i] = st.nextToken();
                      }
                      return result;
             }

    }

    星期四, 七月 19, 2007

    PreparedStatement和Statement

    preparedstatement 优点
     
    1,安全
    2,对于重复数据,速度快
    3,对了重复数据,占用服务器的pool少
     
    Statement优点
     
    1,利于编程,拼sql简单
    2,对于一次性执行,比preparedstatement快

    星期二, 七月 03, 2007

    copy file

    package test;

    import java.io.File;
    import java.io.IOException;
    import java.util.Calendar;


    public class test {

     
     public static void main(String args[]) {
      String filename1 = "C:\\1";
      String filename2 = "C:\\2";
      test test1 = new test();
      try{
      test1.copyFileByPath(filename1, filename2);
      }catch (Exception e) {
       // TODO: handle exception
      }
     }
     
     public void copyFileByPath(String scrPathName,String targetPathName)
      throws NullPointerException,IOException, Exception {
      try{
       File scrPath = new File(scrPathName);
       File targetPath = new File(targetPathName);
       copyFileByPath(scrPath, targetPath);
      }catch (NullPointerException e) {
       //logger.error(dir.getName() + " folder is not exist", e);
       throw e;
      } catch (IOException e) {
       //logger.error(e.getMessage(),e);
       throw e;
      }catch (Exception e) {
       //logger.error(e.getMessage(), e);
       throw e;
      }
     }
     public void copyFileByPath(File scrPath,File targetPath)
      throws NullPointerException,IOException, Exception {
      try {
       String[] fs = scrPath.list();

       for (int i = 0; i < fs.length; i++) {
        File fis = new File(scrPath, fs[i]);
        long currentTime = Calendar.getInstance().getTimeInMillis();
        if (fis.isFile()&&fis.lastModified()<(currentTime-1000*60*1)) {
         copyFile(fis, targetPath);
        } else if (fis.isDirectory()) {
         copyFileByPath(fis, targetPath);
        }
       }
      } catch (NullPointerException e) {
       //logger.error(dir.getName() + " folder is not exist", e);
       throw e;
      } catch (IOException e) {
       //logger.error(e.getMessage(),e);
       throw e;
      }catch (Exception e) {
       //logger.error(e.getMessage(), e);
       throw e;
      }
     }
     
     public void copyFile(File scrFile,File targetPath){
      long lastModifiedTime = scrFile.lastModified();
      
      try{
      File targetFile = new File(targetPath,scrFile.getName());
      java.io.FileInputStream in =new java.io.FileInputStream(scrFile);
         java.io.FileOutputStream out =new java.io.FileOutputStream(targetFile);
         byte Buff[]=new byte[1024];
         int len;
         while((len=in.read(Buff))>-1){
           out.write(Buff,0,len);
         }
         in.close();
         out.close ();
         targetFile.setLastModified(lastModifiedTime);
      }catch (Exception e) {
       // TODO: handle exception
      }
     }
    }

    星期五, 六月 15, 2007

    分布项目团队相关

    分布项目团队相关:
    适用对象:
    1,开源
    2,离岸
    3,xp and scrum
    4,非本地协作
     
    可利用资源:
    1,Internet 协议 (VoIP) 软件、即时通讯软件、电子邮件客户端和 wiki
    2,Mingle和VersionOne ,VNC
    3,Virtual Whiteboards
     
    注意点:
    1,共同的编码标准;源代码控制服务器;一键建立和部署脚本;连续集成;单元测试;错误跟踪;设计模式;以及应用程序块。
    2,项目信息,背景信息(因为难所以更显重要一些)
     
    建议:
    1,kickoff at the start
    2,standup every morning
    3,matrix
    4,TODO list
     
    PS:真实期权是使人们能作出在当前环境下的最优决策的一种方法。本质上它只是对当我们面对如何作出决策时的一个不同视角。真实期权有两面,一面是数学的,一面是心理学的。真实期权的数学方面,根据金融期权理论,给我们提供了一个最优决策过程。关于不确定性和决策的心理学研究(根据神经语言程序学和认知行为理论)告诉我们为什么人们不遵循最优决策过程而结果作出不理性的决定。
     

    星期三, 六月 13, 2007

    70个流行的AJAX应用的演示和源码下载

    1. Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell
    2. AJAX - microlink pattern tutorial : A microlink is a link that opens up content below it.
    3. Ajax BBC News RSS Reader : demo by Nigel Crawley
    4. AJAX Chat in Python with Dojo : at AquaAjax
    5. Ajax Chess : multiplayer chess
    6. Ajax examples at BackBase : examples demonstrating several aspects of the Backbase technology.
    7. Ajax examples at Rico : Inner HTML, JavaScript updater etc.
    8. Ajax examples using ColdFusionMX, SQLServer, SOAP : Contact Manager, NOAA 7 Day Forecast code and demos.
    9. Ajax Feed TV : News feed
    10. Ajax inline dictionary : Highlight any text on this site then right click. A tooltip containing the definition of the selected word should show up.
    11. Ajaxload : Ajax loading gif generator.
    12. Ajax Login Demo : Creating a secure login system using XMLHttpRequest
    13. Ajax Newsletter Signup : A newsletter signup form that shows Thank You on the same page.
    14. ajaxProject : Project Management applicaiton with rich UI
    15. Ajax Rater : A star rating system that uses Ajax.
    16. AJAX-S : An Ajax-based slideshow system.
    17. AJAX Spell Checker : spell check text / form content.
    18. Ajax Toolbox : Tools for the Ajax Developer
    19. Amazon Catalog Tree : Amazon Catalog Tree
    20. Amazon Zuggest : Amazon product suggestion (like google suggest)
    21. Askeet by symfony : Digg-like AJAX interactions; open source
    22. Backbase - Ajax Demos : Ajax demos at BackBase
    23. Basic Ajax Examples : Ping, track changes, drop down, Google suggest hack etc at Clearnova
    24. Behaviour : Fading lists, Sortable lists, Dropout boxen, Shaky lists
    25. chat.app : ajax chat
    26. Chihuahua Word Puzzle : daily word puzzles
    27. Coloir : Ajax Slideshow
    28. DHTML arcade/action games : a collection that demonstrate the power of DHTML
    29. DomAPI : Windows Desktop, Outlook-like, RSS Reader
    30. Drag and Drop Shopping Cart Demo : at CyberDummy
    31. Easy AJAX inline text edit 2.0 : edit a piece of text inline
    32. FileChucker : File upload and progress bar at Encodable.com
    33. Gmail Style Check Username AJAX Demo : at CyberDummy
    34. Google Web Toolkit Example Projects : Hello World, Dynamic Table, Desktop App Clone etc
    35. GreyBox : Pop up window using idea of light box.
    36. FiftyFourEleven: Ajax Examples
    37. IntuiCat - ajax Catalogue : Ajax-based Catalogue Demo
    38. jsLINB programming demos : LINB(Lazy INternet and Browser)
    39. JSlog : Ajax logging tool.
    40. JS/UIX Unix Shell : JS/UIX is an UN*X-like OS for standard web-browsers, written entirely in JavaScript.
    41. Lace : free web chat application
    42. Lightbox : simple, unobtrusive script used to overlay images on the current page.
    43. Leightbox : Light Box with inline div's instead of AJAX calls.
    44. Live Quote Demo : Simple way of creating an updating stock quote table in ajax.
    45. Magnetic Poetry : drag and drop poetry
    46. Metatron Chat Engine : PHP/MySQL/JavaScript powered chat engine
    47. Monket Calendar : online calendar
    48. Multi List Drag Drop Demo : at CyberDummy
    49. NetDirector : open and extensible framework for managing configurations of common open source network services.
    50. nexImage : Image processing demo
    51. Opera Platform : Enabling AJAX applications on mobile phones
    52. Orbeon examples : various examples illustrating the capabilities of OPS, from the OPS Tutorial examples to XForms examples
    53. OVO Suite : Online Virtual Office : virtual office limited demo
    54. phpFreeChat : php Free Chat
    55. S5: A Simple Standards-Based Slide Show System : S5 is a slide show format based entirely on XHTML, CSS, and JavaScript.
    56. script.aculo.us Reflector : image reflector script that uses uses opacity-based fades
    57. Slider Bar Demo : at CyberDummy
    58. SmallestAjax : Smallest Ajax example in the world?
    59. Spell Check demo : by Primal Grasp
    60. Super Maryo World : Japanese game demo
    61. Tacos : Tacos provides a library of useful Tapestry components. This application provides some examples to get you started.
    62. theList : to-do list / bug-tracker
    63. ThickBox : ThickBox is a Lightbox than can show html pages as well as images.
    64. Tooltip.js : Tooltip.js is a simple class to make it possible to add tooltips to your page.
    65. Treehouse Chat : ajax chat
    66. Tudu Lists : open-source to-do lists
    67. WeBoggle : Ajax Boggle
    68. XHTML live Chat : ajax chat
    69. YahooSearchAsYouType : Yahoo search as you type
    70. ZK Demo : demo programs for various components

    星期四, 六月 07, 2007

    java实现FTP功能

    有一个开源项目:edtftpj

    下边是从CSDN转的:

    ---- 在JAVA的编程中,您也许会遇到FTP方面的编程,本文就来演示如何实现它。

    ---- 本程序是由JBUILDER2.0来开发的,为了节约篇幅我只列出主要的三个部份。FtpList 部分是用来显示FTP服务器上的文件(附图略)。GetButton部分为从FTP服务器下传一个文件。PutButton 部分为向FTP服务器上传一个文件。别忘了在程序中还要引入两个库文件(import sun.net.*,import sun.net.ftp.*)。以下是这三部分的JAVA源程序。
    ---- 1)显示FTP服务器上的文件
    void ftpList_actionPerformed(ActionEvent e) {
    String server=serverEdit.getText();
    //输入的FTP服务器的IP地址
    String user=userEdit.getText ();
    //登录FTP服务器的用户名
    String password=passwordEdit.getText();
    //登录FTP服务器的用户名的口令
    String path=pathEdit.getText();
    //FTP服务器上的路径
    try {
    FtpClient ftpClient=new FtpClient();
    //创建FtpClient对象
    ftpClient.openServer (server);
    //连接FTP服务器
    ftpClient.login(user, password);
    //登录FTP服务器
    if (path.length()!=0) ftpClient.cd(path);
    TelnetInputStream is=ftpClient.list();
    int c;
    while ((c=is.read())!=-1) {
    System.out.print ((char) c);}
    is.close();
    ftpClient.closeServer();//退出FTP服务器
    } catch (IOException ex) {;}
    }
    2)从FTP服务器上下传一个文件
    void getButton_actionPerformed(ActionEvent e) {
    String server=serverEdit.getText ();
    String user=userEdit.getText();
    String password=passwordEdit.getText();
    String path=pathEdit.getText();
    String filename=filenameEdit.getText();
    try {
    FtpClient ftpClient=new FtpClient();
    ftpClient.openServer (server);
    ftpClient.login(user, password);
    if (path.length()!=0) ftpClient.cd(path);
    ftpClient.binary();
    TelnetInputStream is=ftpClient.get(filename);
    File file_out=new File(filename);
    FileOutputStream os=new
    FileOutputStream(file_out);
    byte[] bytes=new byte[1024];
    int c;
    while ((c=is.read(bytes))!=-1) {
    os.write(bytes,0,c);
    }
    is.close();
    os.close();
    ftpClient.closeServer();
    } catch (IOException ex) {;}
    }
    3)向FTP服务器上上传一个文件
    void putButton_actionPerformed(ActionEvent e) {
    String server=serverEdit.getText();
    String user=userEdit.getText();
    String password=passwordEdit.getText();
    String path= pathEdit.getText();
    String filename=filenameEdit.getText();
    try {
    FtpClient ftpClient=new FtpClient();
    ftpClient.openServer(server);
    ftpClient.login(user, password);
    if (path.length()!=0) ftpClient.cd(path);
    ftpClient.binary();
    TelnetOutputStream os=ftpClient.put(filename);
    File file_in=new File(filename);
    FileInputStream is=new FileInputStream(file_in);
    byte[] bytes=new byte[1024];
    int c;
    while ((c=is.read (bytes))!=-1){
    os.write(bytes,0,c);}
    is.close();
    os.close();
    ftpClient.closeServer();
    } catch (IOException ex) {;}
    }
    }
    原文地址: http://dev.csdn.net/author/Jason009/a20da6acb30441f6886c03adbb5996c4.html

    星期三, 六月 06, 2007

    eclipse GUI 插件

    http://cloudgarden.com/jigloo/

    关于几种不同的IDENTITY(SQLSERVER)


    SCOPE_IDENTITY、IDENT_CURRENT   和   @@IDENTITY  
    三者在功能上相似,因为它们都返回插入到   IDENTITY   列中的值。    
       
      IDENT_CURRENT   不受作用域和会话的限制,而受限于指定的表。IDENT_CURRENT   返回为任何会话和作用域中的特定表所生成的值。有关更多信息,请参见   IDENT_CURRENT。  
       
      SCOPE_IDENTITY   和   @@IDENTITY   返回在当前会话中的任何表内所生成的最后一个标识值。但是,SCOPE_IDENTITY   只返回插入到当前作用域中的值;@@IDENTITY   不受限于特定的作用域。  
       
      例如,有两个表   T1   和   T2,在   T1   上定义了一个   INSERT   触发器。当将某行插入   T1   时,触发器被激发,并在   T2   中插入一行。此例说明了两个作用域:一个是在   T1   上的插入,另一个是作为触发器的结果在   T2   上的插入。  
    假设   T1   和   T2   都有   IDENTITY   列,@@IDENTITY   和   SCOPE_IDENTITY   将在   T1   上的   INSERT   语句的最后返回不同的值。  
       
      @@IDENTITY   返回插入到当前会话中任何作用域内的最后一个   IDENTITY   列值,该值是插入   T2   中的值。  
       
      SCOPE_IDENTITY()   返回插入   T1   中的   IDENTITY   值,该值是发生在相同作用域中的最后一个   INSERT。如果在作用域中发生插入语句到标识列之前唤醒调用   SCOPE_IDENTITY()   函数,则该函数将返回   NULL   值。  

    星期五, 六月 01, 2007

    db2 sample address

    参考地址:
     
     
     
     
     
    Java サンプル・プログラム
     
  • UNIX の場合:
    sqllib/samples/java
    すべてのサブディレクトリー内の Java サンプル・プログラムの README ファイルが入っています。
    sqllib/samples/java/jdbc
    JDBC サンプル・プログラム・ファイルが入っています。
    sqllib/samples/java/sqlj
    SQLJ サンプル・プログラムが入っています。
    sqllib/samples/xml/java
    JDBC および SQLJ XML サンプルのサブディレクトリーが入っています。
    sqllib/samples/xml/java/jdbc
    README ファイルと JDBC XML サンプル・プログラムが入っています。
    sqllib/samples/xml/java/sqlj
    README ファイルと SQLJ XML サンプル・プログラムが入っています。
    sqllib/samples/java/Websphere
    WebSphere サンプル・プログラムが入っています。
    sqllib/samples/java/plugin
    DB2 コントロール・センターのプラグイン例のファイルが入っています。
    sqllib/samples/java/plugin/doc
    プラグイン・インターフェース用の javadoc ファイルが入っています。
  • Windows の場合;
    sqllib¥samples¥java
    すべてのサブディレクトリー内の Java サンプル・プログラムの README ファイルが入っています。
    sqllib¥samples¥java¥jdbc
    JDBC サンプル・プログラムが入っています。
    sqllib¥samples¥java¥sqlj
    SQLJ サンプル・プログラムが入っています。
    sqllib¥samples¥xml¥java
    JDBC および SQLJ XML サンプルのサブディレクトリーが入っています。
    sqllib¥samples¥xml¥java¥jdbc
    README ファイルと JDBC XML サンプル・プログラムが入っています。
    sqllib¥samples¥xml¥java¥sqlj
    README ファイルと SQLJ XML サンプル・プログラムが入っています。
    sqllib¥samples¥java¥Websphere
    WebSphere サンプル・プログラムが入っています。
    sqllib¥samples¥java¥plugin
    DB2 コントロール・センターのプラグイン例のファイルが入っています。
    sqllib¥samples¥java¥plugin¥doc
    プラグイン・インターフェース用の javadoc ファイルが入っています。
  •