Java 7µÄÖ÷Òª±ä»¯
Devoxx ´ó»á½áÊøÔÚ¼¸ÌìÇ°½áÊøÁË£¬Ò»Î»Óë»áÕ߶Դ˴δó»áµÄÖØÒªÄÚÈݽøÐÐÁË×ܽᣬËûÌáµ½Java 7µÄÖ÷Òª±ä»¯ÈçÏ£º
1.¶ÔcollectionsµÄÖ§³Ö
Java´úÂë
List<String> list = new ArrayList<String>();
list.add(“item”);
String item = list.get(0);
Set<String> set = new HashSet<String>();
set.add(“item”);
Map<String, Integer> map = new HashMap<String, Integer>();
map.put(“key”, 1);
int value = map.get(“key”);
List<String> list = new ArrayList<String>();
list.add("item");
String item = list.get(0);
Set<String> set = new HashSet<String>();
set.add("item");
Map<String, Integer> map = new HashMap<String, Integer>();
map.put("key", 1);
int value = map.get("key");
ÏÖÔÚÄ㻹¿ÉÒÔ£º
Java´úÂë
List<String> list = ["item"];
String item = list[0];
Set<String> set = {“item”};
Map<String, Integer> map = {“key” : 1};
int value = map["key"];
List<String> list = ["item"];
String item = list[0];
Set<String> set = {"item"};
Map<String, Integer> map = {"key" : 1};
int value = map["key"];
2.×Ô¶¯×ÊÔ´¹ÜÀí
Java´úÂë
BufferedReader br = new BufferedReader(new FileReader(path));
try {
return br.readLine();
} finally {
br.close();
}
BufferedReader br = new BufferedReader(new FileReader(path));
try {
return
Ïà¹ØÎĵµ£º
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......
javaÉÏ´«Îļþ
ÐèÒªµÄµÚÈý·½jar°üÓУ¨ÕâÀïʹÓÃapacheµÄ£©
apacheµÄcommons-fileupload£¨ÉÏ´«Óã©£¬commons-io £¨listenerÇåÀíÀàÓã© £¬ commons-beanutils£¨¿ÉÑ¡£©
¾ßÌå²Ù×÷
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
if(ServletFileUp ......
Java
Á÷²Ù×÷
¶ÔÓÚÎÒÃdz£ÓõÄGBKÖУ¬Ó¢ÎÄÊÇÕ¼ÓÃ1¸ö×Ö½Ú£¬ÖÐÎÄÊÇ2¸ö
¶ÔÓÚUTF-8£¬Ó¢ÎÄÊÇ1¸ö£¬ÖÐÎÄÊÇ3¸ö
¶ÔÓÚUnicode£¬Ó¢ÎÄÖÐÎĶ¼ÊÇ2¸ö
Java
µÄÁ÷²Ù×÷·ÖΪ×Ö½ÚÁ÷ºÍ×Ö·ûÁ÷Á½ÖÖ¡£
1¡¢
×Ö½ÚÁ÷
ËùÓеĶÁ²Ù×÷¶¼¼Ì³Ð×ÔÒ»¸ö¹«¹²³¬Àà
java
.io.InputStream
Àà¡£
ËùÓеÄд²Ù×÷¶¼¼Ì³Ð×ÔÒ ......
java³ÌÐòÄÚ´æÖ÷Òª·ÖΪÁË2¸ö²¿·Ö£¬°üÀ¨ stack segment(Õ»ÄÚ´æ)¡¢heap segment(¶ÑÄÚ´æ)¡£
ÔÚ·ÖÎöJava³ÌÐòÄÚ´æ·ÖÅäÇé¿öʱ£¬ÎÒÃÇ´ÓÏÂÃæÕâ¸ö¾³£±»Ê¹ÓõÄÀý×Ó¿ªÊ¼°É¡£
ÏÂÃæ³ÌÐò½«´òӡʲôÄØ£¿
Java´úÂë
String s1&nbs ......
°Ñ֮ǰÏîÄ¿ÖÐдµÄÒ»¸öJavaͨÓÃÑéÖ¤Âë³ÌÐòÕûÀíÁËһϣ¬Óë´ó¼Ò·ÖÏí£¬Ï£ÍûÄÜÅ×שÒýÓñ¡£
Ò»¡¢Ö÷Òª¹¦ÄÜ£º
1¡¢Ö§³Ö´¿Êý×Ö¡¢´óд×Öĸ¡¢Ð¡Ð´×Öĸ£¬¼°Á½Á½»ìºÏ»òÈýÕß»ìºÏÀàÐÍÑéÖ¤Â룻
2¡¢Ö§³Ö×Ô¶¨ÒåÌØÊâ×Ö·ûÅųý£¨Èç0oOi1jI£©£»
3¡¢Ö§³ÖͼƬ¼°ÎÄ×ÖÁ½ÖÖÀàÐÍÑéÖ¤Â룻
4¡¢Ö§³Ö×Ô¶¨ÒåÑéÖ¤ÂëͼƬ´óС£»
5¡¢Ö§³Ö×Ô¶¨Òå¸ÉÈÅÏßÌõÊý£»
......