JAVAÖ®IOÁ÷(³¬ÏêϸµÄJava.io°üµÄ½éÉÜ!)
JAVAÖ®IOÁ÷(³¬ÏêϸµÄJava.io°üµÄ½éÉÜ!)
Ò».InputºÍOutput
1.stream´ú±íµÄÊÇÈκÎÓÐÄÜÁ¦²ú³öÊý¾ÝµÄÊý¾ÝÔ´£¬»òÊÇÈκÎÓÐÄÜÁ¦½ÓÊÕÊý¾ÝµÄ½ÓÊÕÔ´¡£
ÔÚJavaµÄIOÖУ¬ËùÓеÄstream£¨°üÀ¨InputºÍOut stream£©¶¼°üÀ¨Á½ÖÖÀàÐÍ£º
1.1 ÒÔ×Ö½ÚΪµ¼ÏòµÄstream
ÒÔ×Ö½ÚΪµ¼ÏòµÄstream£¬±íʾÒÔ×Ö½ÚΪµ¥Î»´ÓstreamÖжÁÈ¡»òÍùstreamÖÐдÈëÐÅÏ¢¡£ÒÔ×Ö½ÚΪµ¼ÏòµÄstream°üÀ¨ÏÂÃ漸ÖÖÀàÐÍ£º
1) input¡¡stream£º
1) ByteArrayInputStream£º°ÑÄÚ´æÖеÄÒ»¸ö»º³åÇø×÷ΪInputStreamʹÓÃ
2) StringBufferInputStream£º°ÑÒ»¸öString¶ÔÏó×÷ΪInputStream
3) FileInputStream£º°ÑÒ»¸öÎļþ×÷ΪInputStream£¬ÊµÏÖ¶ÔÎļþµÄ¶ÁÈ¡²Ù×÷
4) PipedInputStream£ºÊµÏÖÁËpipeµÄ¸ÅÄÖ÷ÒªÔÚÏß³ÌÖÐʹÓÃ
5) SequenceInputStream£º°Ñ¶à¸öInputStreamºÏ²¢ÎªÒ»¸öInputStream
2) Out¡¡stream
1) ByteArrayOutputStream£º°ÑÐÅÏ¢´æÈëÄÚ´æÖеÄÒ»¸ö»º³åÇøÖÐ
2) FileOutputStream£º°ÑÐÅÏ¢´æÈëÎļþÖÐ
3) PipedOutputStream£ºÊµÏÖÁËpipeµÄ¸ÅÄÖ÷ÒªÔÚÏß³ÌÖÐʹÓÃ
4) SequenceOutputStream£º°Ñ¶à¸öOutStreamºÏ²¢ÎªÒ»¸öOutStream
1.2 ÒÔUnicode×Ö·ûΪµ¼ÏòµÄstream
ÒÔUnicode×Ö·ûΪµ¼ÏòµÄstream£¬±íʾÒÔUnicode×Ö·ûΪµ¥Î»´ÓstreamÖжÁÈ¡»òÍùstreamÖÐдÈëÐÅÏ¢¡£ÒÔUnicode×Ö·ûΪµ¼ÏòµÄstream°üÀ¨ÏÂÃ漸ÖÖÀàÐÍ£º
1) Input¡¡Stream
1) CharArrayReader£ºÓëByteArrayInputStream¶ÔÓ¦
2) StringReader£ºÓëStringBufferInputStream¶ÔÓ¦
3) FileReader£ºÓëFileInputStream¶ÔÓ¦
4) PipedReader£ºÓëPipedInputStream¶ÔÓ¦
2) Out¡¡Stream
1) CharArrayWrite£ºÓëByteArrayOutputStream¶ÔÓ¦
2) StringWrite£ºÎÞÓëÖ®¶ÔÓ¦µÄÒÔ×Ö½ÚΪµ¼ÏòµÄstream
3) FileWrite£ºÓëFileOutputStream¶ÔÓ¦
4) PipedWrite£ºÓëPipedOutputStream¶ÔÓ¦
ÒÔ×Ö·ûΪµ¼ÏòµÄstream»ù±¾É϶ÔÓÐÓëÖ®Ïà¶ÔÓ¦µÄÒÔ×Ö½ÚΪµ¼ÏòµÄstream¡£Á½¸ö¶ÔÓ¦ÀàʵÏֵŦÄÜÏàͬ£¬×ÖÊÇÔÚ²Ù×÷ʱµÄµ¼Ïò²»Í¬¡£ÈçCharArrayReader£ººÍByteArrayInputStreamµÄ×÷Óö¼ÊÇ°ÑÄÚ´æÖеÄÒ»¸ö»º³åÇø×÷ΪInputStreamʹÓã¬Ëù²»Í¬µÄÊÇÇ°Õßÿ´Î´ÓÄÚ´æÖжÁÈ¡Ò»¸ö×Ö½ÚµÄÐÅÏ¢£¬¶øºóÕßÿ´Î´ÓÄÚ´æÖжÁÈ¡Ò»¸ö×Ö·û¡£
1.3 Á½ÖÖ²»ÏÖµ¼ÏòµÄstreamÖ®¼äµÄת»»
InputStreamReaderºÍOutputStreamReader£º°ÑÒ»¸öÒÔ×Ö½ÚΪµ¼ÏòµÄstreamת»»³ÉÒ»¸öÒÔ×Ö·ûΪµ¼ÏòµÄstream¡£
2. streamÌí¼ÓÊôÐÔ
2.1 “ΪstreamÌí¼ÓÊôÐÔ”µÄ×÷ÓÃ
ÔËÓÃÉÏÃæ½éÉܵÄJavaÖвÙ×÷IOµÄAPI£¬ÎÒÃǾͿÉÍê³ÉÎÒÃÇÏëÍê³
Ïà¹ØÎĵµ£º
ÀàµÄ³õʼ»¯ºÍ¶ÔÏó³õʼ»¯ÊÇ JVM ¹ÜÀíµÄÀàÐÍÉúÃüÖÜÆÚÖзdz£ÖØÒªµÄÁ½¸ö»·½Ú£¬Google ÁËÒ»±éÍøÂ磬ÓйØÀà×°ÔØ»úÖƵÄÎÄÕµ¹ÊDz»ÉÙ£¬È»¶øÀà³õʼ»¯ºÍ¶ÔÏó³õʼ»¯µÄÎÄÕ²¢²»¶à£¬ÌرðÊÇ´Ó×Ö½ÚÂëºÍ JVM ²ã´ÎÀ´·ÖÎöµÄÎÄÕ¸üÊÇÏÊÓÐËù¼û¡£
±¾ÎÄÖ÷Òª¶ÔÀàºÍ¶ÔÏó³õʼ»¯È«¹ý³Ì½øÐзÖÎö£¬Í¨¹ýÒ»¸öʵ¼ÊÎÊÌâÒýÈ룬½«Ô´´úÂëת»»³É JVM ×Ö½ÚÂëºó£¬ ......
ÀýÈ磺һ¸ö×Ö·û´®£º123fsf¶á
¸ÄºóҪΪ£º1%2%3%f%s%f%¶á
´úÂëÈçÏÂ
String a="123fsf¶á";
char[] b=a.toCharArray();//×Ö·û´®²ð·Ö³É×Ö·û
&n ......
ÈçºÎ½â¾öOutOfMemoryError: Java heap space
http://www.busfly.cn/csdn/post/OutOfMemoryError-Java-heap-space.html
ʹÓÃJava³ÌÐò´ÓÊý¾Ý¿âÖвéѯ´óÁ¿µÄÊý¾Ýʱ³öÏÖÒì³£:
java.lang.OutOfMemoryError: Java heap space
ÔÚJVMÖÐÈç¹û98£¥µÄʱ¼äÊÇÓÃÓÚGCÇÒ¿ÉÓÃµÄ Heap size ²»×ã2£¥µÄʱºò½«Å׳ö´ËÒì³£ÐÅÏ¢¡£
JVM¶ÑµÄÉè ......
javaÖеÄ×Ö·û´®Ò²ÊÇÒ»Á¬´®µÄ×Ö·û¡£µ«ÊÇÓëÐí¶àÆäËûµÄ¼ÆËã»úÓïÑÔ½«×Ö·û´®×÷Ϊ×Ö·ûÊý×é´¦Àí²»Í¬£¬Java½«×Ö·û´®×÷ΪStringÀàÐͶÔÏóÀ´´¦Àí¡£½«×Ö·û´®×÷ΪÄÚÖõĶÔÏó´¦ÀíÔÊÐíJavaÌṩʮ·Ö·á¸»µÄ¹¦ÄÜÌØÐÔÒÔ·½±ã´¦Àí×Ö·û´®¡£ÏÂÃæÊÇһЩʹÓÃƵÂʱȽϸߵĺ¯Êý¼°ÆäÏà¹Ø˵Ã÷¡£
StringÏà¹Øº¯Êý
1)substring()
ËüÓÐÁ½ÖÖÐÎʽ£¬µÚÒ»ÖÖ ......
ºÇºÇ£¡»¹ÊÇÏȸø´ó¼Ò³ö¸öÌâ°É£¡
public class PreferenceTest {
public int testVar = 0;
/**
* create data: 2009-12-30</br> Just for me to test preference.
*
* @author XiangJie
* @param args
*
*/
public static void main(String[] args) {
// TODO Auto-generated method stu ......