目前分類:Java筆記本 (9)

瀏覽方式: 標題列表 簡短摘要
以前上班的時候都會為了訂便當苦惱
今天上網竟然很神奇的看到有人實做出來
看來訂便當這種事情還真是困擾不少人(笑)
看他用的技術,看起來不是很難

npitt 發表在 痞客邦 留言(1) 人氣()

Copy a file

import java.io.*;            public class JCopy{            public static void main(String args[]){            try {            JCopy j = new JCopy();            j.copyFile(new File(args[0]),new File(args[1]));            }            catch (Exception e) {            e.printStackTrace();            }            }            public void copyFile(File in, File out) throws Exception {            FileInputStream fis  = new FileInputStream(in);            FileOutputStream fos = new FileOutputStream(out);            byte[] buf = new byte[1024];            int i = 0;            while((i=fis.read(buf))!=-1) {            fos.write(buf, 0, i);            }            fis.close();            fos.close();            }            }
[JDK1.4 using the java.nio package]
import java.nio.channels.*;            import java.io.*;            public class JCopy2{            public static void main(String args[]){            try {            JCopy2 j = new JCopy2();            j.copyFile(new File(args[0]),new File(args[1]));            }            catch (Exception e) {            e.printStackTrace();            }            }            public void copyFile(File in, File out) throws Exception {            FileChannel sourceChannel = new            FileInputStream(in).getChannel();            FileChannel destinationChannel = new            FileOutputStream(out).getChannel();            sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);            // or            //  destinationChannel.transferFrom(sourceChannel, 0, sourceChannel.size());            sourceChannel.close();            destinationChannel.close();            }            }
NOTE:
In win2000 , the transferTo() does not transfer files > than 2^31-1 bytes. it throws an exception of "java.io.IOException: The parameter is incorrect"
In solaris8 , Bytes transfered to Target channel are 2^31-1 even if the source channel file is greater than 2^31-1
In LinuxRH7.1 , it gives an error of java.io.IOException: Input/output error

npitt 發表在 痞客邦 留言(0) 人氣()

會知道這個是同事Elliot介紹的
說真的
覺得這真是個滿神奇的opensource
未何會覺得神奇,簡單來說就是"簡單"

npitt 發表在 痞客邦 留言(0) 人氣()

Struts VS Turbine
轉載自
http://www.cn-java.com/target/news.php?news_id=2335
Struts 和 Turbine 我都用過並且做過項目,我想在這個問題上我還是有點發言權的:-)

npitt 發表在 痞客邦 留言(0) 人氣()

Velocity
偶然在網路上發現這個名詞,不知道之後會不會成為主流的技術之一

官方網站

npitt 發表在 痞客邦 留言(0) 人氣()


l 其中:
Collections => Collection是所有List跟Set的始祖,List必須以特定次序來持有物件,Set無法擁有重複元素
========================

npitt 發表在 痞客邦 留言(0) 人氣()

SQL Data Type 與 Java class 對應表

SQL Type       Java class
-------------------------------------------

npitt 發表在 痞客邦 留言(0) 人氣()

連接 Mysql Database Server:
-------------------------------------------------------------------------------
mysql 不支持 unicode,所以比較麻煩。
先將 URL String 設置成 encoding 為 Big5

npitt 發表在 痞客邦 留言(0) 人氣()

Java Web 程式設計 sendRedirect與requestDispatcher的限制
1. RequestDispatcher限制

當於程式中使用以下敘述

npitt 發表在 痞客邦 留言(0) 人氣()