´«ÖDz¥¿Íjavaѧϰ5 ÊäÈëÊä³öÁ÷
½ñÌìÎÒѧϰÁËJavaÊäÈëÊä³öÁ÷
Java ÓïÑÔ²ÉÓÃÁ÷µÄ»úÖÆʵÏÖʵÏÖÊäÈëÓëÊä³ö¡£ÊäÈëÊä³öÁ÷£ºÊµÏÖÊäÈëÊä³ö²Ù×÷µÄÀà¿âÔÚJava.io.°üÖУº
1.
File¶ÔÏóÊÇFileÀàµÄʵÀý£¬File¶ÔÏó¶ÔÓ¦Ò»¸öĿ¼»òÎļþ£¬¶ÔÏóµÄÊôÐÔ°üÀ¨Îļþ·¾¶¡¢Ãû×Ö¡¢Îļþ³¤¶È¡¢¿É·ñ¶Áд¡£File¶ÔÏóÖ»ÓÃÀ´ÃüÃûÎļþ£¬²éѯÎļþÊôÐÔ¡¢ºÍ´¦ÀíĿ¼£¬²»ÌṩÎļþµÄ¶Áд²Ù×÷¡£
ÀýÈ磺´´½¨File¶ÔÏóµÄ´úÂ룺File f1=new File(“/myfile/mefile.txt”);
File f2=new File(“/myfile”,”myfile.txt”);
ÏÂÃæÊÇÒ»¸öÎļþµÄ¸´ÖƳÌÐò£¬½«Ä³¸öÎļþµÄÄÚÈÝÈ«²¿¸´ÖƵ½ÁíÒ»¸öÎļþÖÐ
import java.io.*;
class Example
{
public static void main(String[] args)
{
File inputFile = new File("a.txt");
File outputFile = new File("b.txt");
int ch;
try
{
FileReader in=new FileReader(inputFile);
FileWriter out=new FileWriter(outputFile);
while((ch=in.read())!=-1)
{
out.write(ch);
}
&nbs
Ïà¹ØÎĵµ£º
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......
¹Ø¼ü×Ö: thread
³ÌÐòÊǺܼòÒ׵ġ£È»¶ø£¬ÔÚ±à³ÌÈËÔ±ÃæÇ°£¬¶àÏ̳߳ÊÏÖ³öÁËÒ»×éеÄÄÑÌ⣬Èç¹ûûÓб»Ç¡µ±µÄ½â¾ö£¬½«µ¼ÖÂÒâÍâµÄÐÐΪÒÔ¼°Ï¸Î¢µÄ¡¢ÄÑÒÔ·¢ÏֵĴíÎó¡£
ÔÚ±¾ÆªÎÄÕÂÖУ¬ÎÒÃÇÕë¶ÔÕâЩÄÑÌâÖ®Ò»£ºÈçºÎÖжÏÒ»¸öÕýÔÚÔËÐеÄÏ̡߳£
Öжϣ¨Interrupt£©Ò»¸öÏß³ÌÒâζ×ÅÔÚ¸ÃÏß³ÌÍê³ÉÈÎÎñ֮ǰֹͣÆäÕýÔÚ½øÐеÄÒ»ÇУ ......
ÖµÀàÐÍÊÇ´æ´¢ÔÚÄÚ´æÖеĶÑÕ»£¨ÒÔºó¼ò³ÆÕ»£©£¬¶øÒýÓÃÀàÐ͵ıäÁ¿ÔÚÕ»Öнö½öÊÇ´æ´¢ÒýÓÃÀàÐͱäÁ¿µÄµØÖ·£¬¶øÆä±¾ÉíÔò´æ´¢ÔÚ¶ÑÖС£
==²Ù×÷±È½ÏµÄÊÇÁ½¸ö±äÁ¿µÄÖµÊÇ·ñÏàµÈ£¬¶ÔÓÚÒýÓÃÐͱäÁ¿±íʾµÄÊÇÁ½¸ö±äÁ¿ÔÚ¶ÑÖд洢µÄµØÖ·ÊÇ·ñÏàͬ£¬¼´Õ»ÖеÄÄÚÈÝÊÇ·ñÏàͬ¡£
equals²Ù×÷±íʾµÄÁ½¸ö±äÁ¿ÊÇ·ñÊǶÔͬһ¸ö¶ÔÏóµÄÒýÓ㬼´¶ÑÖеÄÄÚÈÝÊÇ·ñ ......