Java ÊäÈë/Êä³ö
ÔÚjavaÓïÑÔÖУ¬I/OµÄ·½Ê½ÊÇÁ÷µÄ·½Ê½¡£Á÷£¨stream£©ÕâÊǸöѧϰjavaÊäÈëÊä³öµÄ×î»ù±¾µÄ¸ÅÄî¡£Á÷ÊÇ×Ö½Ú´ÓÔ´µ½Ä¿µÄµÄÓÐÐòÐòÁС£Ò»·½ÃæÊÇ×Ö½Ú£¬Ò»·½ÃæÊÇÓÐÐòµÄ¡£Á÷ÃèÊöµÄÊÇÒ»¸ö¹ý³Ì£¬Ë³ÐòÑϸñ¡£Ò»¸öÐèÒª¼üÅÌÊäÈëµÄ³ÌÐò¿ÉÒÔÓÃÁ÷À´×öµ½ÕâÒ»µã¡£Á½ÖÖ»ù±¾µÄÁ÷ÊÇ£ºÊäÈëÁ÷ºÍÊä³öÁ÷¡£Äã¿ÉÒÔ´ÓÊäÈëÁ÷¶Á£¬µ«Äã²»ÄܶÔËüд¡£Òª´ÓÊäÈëÁ÷¶ÁÈ¡×Ö½Ú£¬±ØÐëÓÐÒ»¸öÓëÕâ¸öÁ÷Ïà¹ØÁªµÄ×Ö·ûÔ´¡£ÕâЩ¶«Î÷¶¼·ÅÔÚjava.io.*Õâ¸ö°üÀïÁË¡£ioÊÇjavaµÄµÚÒ»´ó°ü¡£ÔÚjava.io °üÖУ¬ÓÐһЩÁ÷ÊǽáµãÁ÷£¬¼´ËüÃÇ¿ÉÒÔ´ÓÒ»¸öÌض¨µÄµØ·½¶Áд£¬ÀýÈç´ÅÅÌ»òÕßÒ»¿éÄÚ´æ¡£ÆäËûÁ÷³Æ×÷¹ýÂËÁ÷¡£Ò»¸ö¹ýÂËÆ÷ÊäÈëÁ÷ÊÇÓÃÒ»¸öµ½ÒÑ´æÔÚµÄÊäÈëÁ÷µÄÁ¬½Ó´´½¨µÄ¡£´Ëºó£¬µ±ÄãÊÔͼ´Ó¹ýÂËÊäÈëÁ÷¶ÔÏó¶Áʱ£¬ËüÏòÄãÌṩÀ´×ÔÁíÒ»¸öÊäÈëÁ÷¶ÔÏóµÄ×Ö·û¡£
³£¼ûµÄ¼¸ÖÖÁ÷£º
×Ö½ÚÁ÷£º´«×ֽڵġ£ÒÔ8λ×Ö½ÚΪµ¥Î»½øÐжÁд£¬ÒÔInputStreamÓëOutputStreamΪ»ù´¡Àà
×Ö·ûÁ÷: ´«×Ö·ûµÄ¡£ÒÔ16λ×Ö·ûΪµ¥Î»½øÐжÁд£¬ÒÔReaderÓëWriterΪ»ù´¡Àà
ÎļþÁ÷: ´«ÎļþµÄ¡£ÊôÓÚ½ÚµãÁ÷£¬¶ÔÎļþ¶Áд£¬´«Êä¡£ÀïÃæµÄÀàºÜ¶à¡£
ÐòÁл¯£º´«¶ÔÏóµÄ¡£Ò»¸ö¶ÔÏóÔõô¶Á°¡£¬Ö»Óбä³É¶þ½øÖƲſÉÒÔ¶Á£¬Õâ¾ÍÊÇÐòÁл¯¡£
ʵ¼ù£º //ÕâÊÇÒ»¸ö×Ö½ÚÁ÷µÄÀý×Ó£¬ÒÔInputStreamÓëOutputStreamΪ»ù´¡Àà
import java.io.*;
class ByteArrayOutputStreamDemo {
public static void main(String args[]) throws IOException {
ByteArrayOutputStream f = new ByteArrayOutputStream();
String s = "This should end up in the array";
byte buf[] = s.getBytes();
f.write(buf);
System.out.println("Buffer as a string");
System.out.println(f.toString());
System.out.println("Into array");
byte b[] = f.toByteArray();
for (int i=0; i<b.length; i++) {
System.out.print((char) b[i]);}
System.out.println("\nTo an OutputStream()");
//Êä³öµ½Îļþtest.txtÖÐ
OutputStream f2 = new FileOutputStream("test.txt");
f.writeTo(f2);
f2.close();
System.out.println("Doing a reset");
f.reset();
for (int i=0; i<3; i++)
f.write('X');
System.out.println(f.toString());}}
//×Ö·ûÁ÷µÄÀý×Ó£¬ÒÔReaderÓëWriterΪ»ù´¡Àà
import java.io.*;
public class CharArrayReaderDemo {
public static void main(String args[]) throws IOException {
String tmp = "abcdefghijklmnopqrstuvwxyz";
int length = tmp.length();
cha
Ïà¹ØÎĵµ£º
Javaѧϰ·¾¶£¨Ò»£©¹¤¾ßƪ
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJDKÊÇSun¹«Ë¾·¢²¼µÄJDK£¬³ýÁËSunÖ®Í⣬»¹Óкܶ๠......
һЩ³õѧJAVAµÄÅóÓÑ¿ÉÄÜ»áÓöµ½JAVAµÄÊý¾ÝÀàÐÍÖ®¼äת»»µÄ¿àÄÕ£¬ÀýÈ磬ÕûÊýºÍfloat,doubleÐÍÖ®¼äµÄת»»£¬ÕûÊýºÍStringÀàÐÍÖ®¼äµÄת»»£¬ÒÔ¼°´¦Àí¡¢ÏÔʾʱ¼ä·½ÃæµÄÎÊÌâµÈ¡£ÏÂÃæ±ÊÕ߾Ϳª·¢ÖеÄһЩÌå»á½éÉܸø´ó¼Ò¡£
ÎÒÃÇÖªµÀ£¬JavaµÄÊý¾ÝÀàÐÍ·ÖΪÈý´óÀ࣬¼´²¼¶ûÐÍ¡¢×Ö·ûÐͺÍÊýÖµÐÍ£¬¶øÆäÖÐÊýÖµÐÍÓÖ·ÖΪÕûÐͺ͸¡µãÐÍ£»Ïà¶Ô ......
Èí»Ø³µ£¨Soft Return£©£ºÈí»Ø³µÊÇÔÚ×Ö´¦Àí³ÌÐòÖÐ×÷Ϊ×Ô¶¯ÒÆÐй¦ÄܵÄÒ»²¿·Ö×Ô¶¯²åÈëµÄ£¬Ò²½Ð»»Ðзû£¬ÔÚwordÖп´²»¼û¡£Èç¹ûÎı¾
Ò»Ðеij¤¶È³¬¹ýÎĵµËù¶¨ÒåµÄÓұ߾àʱ£¬¼´µ±Ç°ÐÐûÓÐ×ã¹»µÄ¿Õ¼ä·ÅÖÃÏÂÒ»¸ö×Ö·ûʱ£¬ÎÄ×Ö´¦ÀíÈí¼þ½«ÔÚÕâÒ»ÐÐÎı¾µÄĩβ×Ô¶¯²åÈëÒ»
¸öÈí»Ø³µ·û£¬Îı¾ÁíÆðÒ»ÐС£Õâ¸öÈí»Ø³µ·ûÊÇÓɱ༳ÌÐò×Ô¶¯² ......
×î½ü×ö¸öÏîÄ¿£¬¾ÍÊÇҪȡµÃcpuÕ¼ÓÐÂʵȵȵÄϵͳÐÅÏ¢£¬Ò»¿ªÊ¼ÒÔΪҪÓö¯Ì¬Á´½Ó¿âÁË£¬µ«ºóÀ´·¢ÏÖ¿ÉÒÔÏñÏÂÃæÕâÑù×ö£¬²»È¥µ÷ÓÃjni£¬ÕâÑùÊ¡È¥Á˺ܶ࿴м¼ÊõµÄʱ¼äo(∩_∩)o...
ÔÚJavaÖУ¬¿ÉÒÔ»ñµÃ×ܵÄÎïÀíÄڴ桢ʣÓàµÄÎïÀíÄÚ´æ¡¢ÒÑʹÓõÄÎïÀíÄÚ´æµÈÐÅÏ¢£¬ÏÂÃæÀý×Ó¿ÉÒÔÈ¡µÃÕâЩÐÅÏ¢£¬²¢ÇÒ»ñµÃÔÚWindowsϵÄÄÚ´æʹÓà......