以前上班的時候都會為了訂便當苦惱
今天上網竟然很神奇的看到有人實做出來
看來訂便當這種事情還真是困擾不少人(笑)
看他用的技術,看起來不是很難
目前分類:Java筆記本 (9)
- Oct 27 Fri 2006 09:41
[新奇]訂便當系統
- Aug 30 Tue 2005 11:57
Copy a file
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(); } } |
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
- Aug 01 Mon 2005 18:24
XStream
會知道這個是同事Elliot介紹的
說真的
覺得這真是個滿神奇的opensource
未何會覺得神奇,簡單來說就是"簡單"
- Jun 07 Tue 2005 15:12
Struts VS Turbine
Struts VS Turbine
轉載自
http://www.cn-java.com/target/news.php?news_id=2335
Struts 和 Turbine 我都用過並且做過項目,我想在這個問題上我還是有點發言權的:-)
- Jan 24 Mon 2005 10:51
java_util容器用法的整理
l 其中:
Collections => Collection是所有List跟Set的始祖,List必須以特定次序來持有物件,Set無法擁有重複元素
========================
- Jan 21 Fri 2005 14:28
SQL Data Type 與 Java class 對應表
SQL Data Type 與 Java class 對應表
SQL Type Java class
-------------------------------------------
- Jan 21 Fri 2005 14:26
Java 使用 Mysql 時的中文處理
連接 Mysql Database Server:
-------------------------------------------------------------------------------
mysql 不支持 unicode,所以比較麻煩。
先將 URL String 設置成 encoding 為 Big5
- Jan 21 Fri 2005 14:24
sendRedirect與requestDispatcher的限制
Java Web 程式設計 sendRedirect與requestDispatcher的限制
1. RequestDispatcher限制
當於程式中使用以下敘述