JAVA¹æÔò Öм¶Æª
±¾ÎĽéÉܵÄJAVA¹æÔòµÄ˵Ã÷·ÖΪ3¸öÖ÷Òª¼¶±ð£¬Öм¶ÊÇƽʱ¿ª·¢ÓõıȽ϶àµÄ¼¶±ð£¬ÔÚ½ñºó½«Â½Ðøд³öÆäËûµÄ¹æÔò¡£×ñÊØÁËÕâЩ¹æÔò¿ÉÒÔÌá¸ß³ÌÐòµÄЧÂÊ¡¢Ê¹´úÂëÓÖ¸üºÃµÄ¿É¶ÁÐԵȡ£
£¨1£© ÔÚfinally·½·¨Àï¹Øµôinput»òÕßoutput ×ÊÔ´
ÔÙ·½·¨ÌåÀïÃ涨ÒåÁËinput»òÕßoutputÁ÷µÄ»°£¬ÐèÒªÔÚfinallyÀïÃæ°ÑËü¹Øµô¡£
ÒÔÏÂÕ⼸ÖÖµ÷Óò»ÐèÒª×ñÊØÕâÌõ¹æÔò£¬ÒòΪcolse()·½·¨²»Æð×÷Ó㺣©
java.io.StringWriter java.io.ByteArrayOutputStream java.io.ByteArrayInputStream
Èç¹ûÔÙ·½·¨·µ»ØµÄʱºòûÓе÷ÓÃclose()·½·¨À´ÊÍ·Åinput()ºÍoutput()µÄ×ÊÔ´µÄ»°£¬»áµ¼ÖÂÒ»¸öϵͳ×ÊԴй©¡£¶øÇÒÔÚÈκÎÇé¿ö϶¼ÒªÈ·¶¨ÔÚ·µ»ØÈ«µ÷ÓÃÁËclose() ·½·¨£¬°üÀ¨³öÏÖÒì³£µÄʱºò¡£ËùÒÔÐèÒªÔÚfinally·½·¨ÀïÃæ¼ÓÈëÕâ¸ö·½·¨¡£ÕâÑù¾Í±£Ö¤ÁËÔÚÈκÎÇé¿ö϶¼»á¹Ø±Õ×ÊÔ´¡£
´íÎóʾÀý£º
public class CIO {
public void method (java.io.File f) {
java.io.FileInputStream fis = null;
try {
fis = new java.io.FileInputStream (f);
fis.read ();
fis.close ();
} catch (java.io.FileNotFoundException e1) {
System.out.println("File not found");
} catch (java.io.IOException e2) {
System.out.println("I/O Exception");
}
// Èç¹û³öÏÖÒì³££¬ÕâÀï¾Í²»Äܱ£Ö¤¹Ø±Õ×ÊÔ´¡£
}
}
ÐÞÕýºóµÄ´úÂ룺
public class CIOFixed {
public void method (java.io.File f) {
java.io.FileInputStream fis = null;
try {
&n
Ïà¹ØÎĵµ£º
¡¡¡¡ÔÚƽʱ¹¤×÷ÖУ¬ÄÑÃâ»áÓöµ½°Ñ XML ×÷ΪÊý¾Ý´æ´¢¸ñʽ¡£Ãæ¶ÔÄ¿Ç°ÖÖÀà·±¶àµÄ½â¾ö·½°¸£¬Äĸö×îÊʺÏÎÒÃÇÄØ£¿ÔÚÕâƪÎÄÕÂÖУ¬ÎÒ¶ÔÕâËÄÖÖÖ÷Á÷·½°¸×öÒ»¸ö²»ÍêÈ«ÆÀ²â£¬½ö½öÕë¶Ô±éÀú XML Õâ¿éÀ´²âÊÔ£¬ÒòΪ±éÀú XML Êǹ¤×÷ÖÐʹÓÃ×î¶àµÄ£¨ÖÁÉÙÎÒÈÏΪ£©¡£
¡¡¡¡Ô¤ ±¸
¡¡¡¡²âÊÔ»·¾³£º
¡¡¡¡AMD ¶¾Áú1.4G OC 1.5G¡¢256M DDR333¡¢Wind ......
Àà¼ÓÔØÆ÷ÊÇ Java ÓïÑÔµÄÒ»¸ö´´Ð£¬Ò²ÊÇ Java ÓïÑÔÁ÷ÐеÄÖØÒªÔÒòÖ®Ò»¡£ËüʹµÃ Java Àà¿ÉÒÔ±»¶¯Ì¬¼ÓÔص½ Java ÐéÄâ»úÖв¢Ö´ÐС£Àà¼ÓÔØÆ÷´Ó JDK 1.0 ¾Í³öÏÖÁË£¬×î³õÊÇΪÁËÂú×ã Java Applet µÄÐèÒª¶ø¿ª·¢³öÀ´µÄ¡£Java Applet ÐèÒª´ÓÔ¶³ÌÏÂÔØ Java ÀàÎļþµ½ä¯ÀÀÆ÷Öв¢Ö´ÐС£ÏÖÔÚÀà¼ÓÔØÆ÷ÔÚ Web ÈÝÆ÷ºÍ OSGi Öеõ½Á˹㷺µÄʹÓá ......
1£©DOM£¨JAXP Crimson½âÎöÆ÷£©
DOMÊÇÓÃÓëƽ̨ºÍÓïÑÔÎ޹صķ½Ê½±íʾXMLÎĵµµÄ¹Ù·½W3C±ê×¼¡£DOMÊÇÒÔ²ã´Î½á¹¹×éÖ¯µÄ½Úµã»òÐÅϢƬ¶ÏµÄ¼¯ºÏ¡£Õâ¸ö²ã´Î½á¹¹ÔÊÐí¿ª·¢ÈËÔ±ÔÚÊ÷ÖÐÑ°ÕÒÌض¨ÐÅÏ¢¡£·ÖÎö¸Ã½á¹¹Í¨³£ÐèÒª¼ÓÔØÕû¸öÎĵµºÍ¹¹Ôì²ã´Î½á¹¹£¬È»ºó²ÅÄÜ×öÈκι¤×÷¡£ÓÉÓÚËüÊÇ»ùÓÚÐÅÏ¢²ã´ÎµÄ£¬Òò¶øDO ......
·¢ËÍemailÓ¦Óã»
package mail;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import sun.misc.BASE64Encoder;
public class Mail {
// ¶¨Òå·¢¼þÈËÏÔʾÃû³Æ¡¢·¢¼þÈË¡¢ÊÕ¼þÈË¡¢³ËÍ¡¢SMTP·þÎñÆ÷¡¢Óû§Ãû¡¢ÃÜÂë¡¢Ö÷Ìâ¡¢ÄÚÈݵÈ
private String d ......
±¾ÎĽéÉܵÄJAVA¹æÔòµÄ˵Ã÷·ÖΪ5¸ö¼¶±ð£¬¼¶±ð1ÊÇ×î»ù±¾Ò²ÊÇ×îÖØÒªµÄ¼¶±ð£¬ÔÚ½ñºó½«Â½Ðøд³öÆäËûµÄ¹æÔò¡£×ñÊØÁËÕâЩ¹æÔò¿ÉÒÔÌá¸ß³ÌÐòµÄЧÂÊ¡¢Ê¹´úÂëÓиüºÃµÄ¿É¶ÁÐԵȡ£
£¨1£© ±ÜÃâʹÓÃNEW¹Ø¼ü×ÖÀ´´´½¨String¶ÔÏó¡£
°ÑÒ»¸öString³£Á¿copyµ½String ¶ÔÏóÖÐͨ³£ÊǶàÓà¡¢ÀË·Ñʱ¼äµÄ
Public class test{
&nbs ......