JavaʵÏÖÎļþ¿½±´µÄ4ÖÖ·½·¨
ʹÓà java ½øÐÐÎļþ¿½±´ ÏàÐźܶàÈ˶¼»áÓÃ,,²»¹ýЧÂÊÉÏÊÇ·ñ×îºÃÄØ?
×î½ü¿´ÁË¿´NIO¾ö¶¨ÊÔÒ»ÊÔ java NIO µ½µ×ÓÐʲôÐÔÄܵÄÌáÉý.
µÚÒ»ÖÖ·½·¨:¹ÅÀϵķ½Ê½
public static long forJava(File f1,File f2) throws Exception{
long time=new Date().getTime();
int length=2097152;
FileInputStream in=new FileInputStream(f1);
FileOutputStream out=new FileOutputStream(f2);
byte[] buffer=new byte[length];
while(true){
int ins=in.read(buffer);
if(ins==-1){
in.close();
out.flush();
out.close();
return new Date().getTime()-time;
}else
out.write(buffer,0,ins);
}
}
·½·¨µÄ2²ÎÊý·Ö±ðÊÇÔʼÎļþ,ºÍ¿½±´µÄÄ¿µÄÎļþ.ÕâÀï²»×ö¹ý¶à½éÉÜ.
ʵÏÖ·½·¨ºÜ¼òµ¥,·Ö±ð¶Ô2¸öÎļþ¹¹½¨ÊäÈëÊä³öÁ÷,²¢ÇÒʹÓÃÒ»¸ö×Ö½ÚÊý×é×÷ΪÎÒÃÇÄÚ´æµÄ»º´æÆ÷, È»ºóʹÓÃÁ÷´Óf1 ÖжÁ³öÊý¾Ýµ½»º´æÀï,ÔÚ½«»º´æÊý¾Ýдµ½f2ÀïÃæÈ¥.ÕâÀïµÄ»º´æÊÇ2MBµÄ×Ö½ÚÊý×é
µÚ2ÖÖ·½·¨:ʹÓÃNIOÖеĹܵÀµ½¹ÜµÀ´«Êä
public static long forTransfer(File f1,File f2) throws Exception{
long time=new Date().getTime();
int length=2097152;
FileInputStream in=new FileInputStream(f1);
FileOutputStream out=new FileOutputStream(f2);
FileChannel inC=in.getChannel();
FileChannel outC=out.getChannel();
int i=0;
while(true){
if(inC.position()==inC.size()){
inC.close();
outC.cl
Ïà¹ØÎĵµ£º
game
server responsibility:
Initialize
the server socke;
Wait
for a client to connect;
Accept
the client connection;
Create
a daemon thread to support the clien;
Go
back to step 2.
game daemon responsibility:
Accept
client player connection;
Pair
......
package OALogic.sql.data;
import java.io.*;
public class FileOperate {
public FileOperate() {
}
public static void main(String args[]){
newFolder("D:/100");
}
/**
......
Javaѧϰ·Ïß
ÏÈѧϰj2se
Ҫѧϰj2ee¾ÍÒªÏÈѧϰj2se£¬¸Õ¿ªÊ¼Ñ§Ï°j2seÏȽ¨Ò鲻ҪʹÓÃIDE£¬È»ºó½¥½¥µÄ¹ý¶Éµ½Ê¹ÓÃIDE¿ª·¢£¬±Ï¾¹ÓÃËü·½±ãÂѧϰj2seÍÆ¼öÁ½±¾Ê飬¡¶java2ºËÐļ¼ÊõÒ»¶þ¾í¡·£¬¡¶java±à³Ì˼Ïë¡·£¬¡¶javaģʽ¡·¡£ÆäÖС¶java±à³Ì˼Ïë¡·ÒªÑжÁ£¬¾«¶Á¡£ÕâÒ»¶Îʱ¼äÊÇ»ù±¾¹¦Ñ§Ï°£¬Ê±¼ä»áºÜ³¤£¬Ò²¿ÉẠ̈ܺܶ¬ÕâÒª¿´Ñ§Ï ......
±³¾°¼ò½é£ºKMPËã·¨ÓÃÀ´´¦Àí×Ö·û´®Æ¥ÅäµÄ¡£¸øÄãA,BÁ½¸ö×Ö·û´®£¬¼ì²éB´®ÊÇ·ñÊÇA´®µÄ×Ó´®£¬ÀàËÆÓÚJavaµÄString.indexOf("")¡£Ö®ËùÒÔ½Ð×öKMP£¬ÊÇÒòΪÕâ¸öËã·¨ÊÇÓÉKnuth¡¢Morris¡¢PrattÈý¸öÌá³öÀ´µÄ£¬È¡ÁËÕâÈý¸öÈ˵ÄÃû×ÖµÄÍ·Ò»¸ö×Öĸ¡£
ÔÀí½éÉÜ£ºÕÒµ½Æ¥Åäʧ°ÜʱµÄ×îºÏÊʵĻØÍËλÖ㬶ø²»ÊǼòµ¥µÄ»ØÍ˵½×Ó´®µÄµÚÒ»¸ö×Ö·û£¨³£¹ ......
1.±à³Ì½ç×îÖøÃûµÄÒ»¾ä»°“Hello world!”,ÈκÎÒ»¸ö³ÌÐòÔ±Æð²½Ê±±ØÓöµÄÓï¾ä
public class HelloWorld {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.print("Hello World!");
......