Java ¶ÁÈ¡Îı¾Îļþ
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
/**
* @author new
*
*/
public class ReadDataTest
{
/**
* @param args
*/
String url="D:/java.txt";
String str="";
char[] ch=new char[1024];
StringBuffer sb=new StringBuffer();
public String ReadData()
{
try
{
FileReader fr=new FileReader(new File(url));
int d = fr.read(ch);
while(d!=-1)
{
String s=new String(ch,0,d);
sb.append(s);
d = fr.read(ch);
}
str=sb.toString();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return str;
}
public static void main(String[] args)
{
ReadDataTest at=new ReadDataTest();
String ss=at.ReadData();
System.out.println(ss);
}
}
Ïà¹ØÎĵµ£º
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......
ÀàµÄ³õʼ»¯ºÍ¶ÔÏó³õʼ»¯ÊÇ JVM ¹ÜÀíµÄÀàÐÍÉúÃüÖÜÆÚÖзdz£ÖØÒªµÄÁ½¸ö»·½Ú£¬Google ÁËÒ»±éÍøÂ磬ÓйØÀà×°ÔØ»úÖƵÄÎÄÕµ¹ÊDz»ÉÙ£¬È»¶øÀà³õʼ»¯ºÍ¶ÔÏó³õʼ»¯µÄÎÄÕ²¢²»¶à£¬ÌرðÊÇ´Ó×Ö½ÚÂëºÍ JVM ²ã´ÎÀ´·ÖÎöµÄÎÄÕ¸üÊÇÏÊÓÐËù¼û¡£
±¾ÎÄÖ÷Òª¶ÔÀàºÍ¶ÔÏó³õʼ»¯È«¹ý³Ì½øÐзÖÎö£¬Í¨¹ýÒ»¸öʵ¼ÊÎÊÌâÒýÈ룬½«Ô´´úÂëת»»³É JVM ×Ö½ÚÂëºó£¬ ......
1. ³éÏó
³éÏó¾ÍÊǺöÂÔÒ»¸öÖ÷ÌâÖÐÓ뵱ǰĿ±êÎ޹صÄÄÇЩ·½Ã棬ÒÔ±ã¸ü³ä·ÖµØ×¢ÒâÓ뵱ǰĿ±êÓйصķ½Ãæ¡£³éÏó²¢²»´òËãÁ˽âÈ«²¿ÎÊÌ⣬¶øÖ»ÊÇÑ¡ÔñÆäÖеÄÒ»²¿·Ö£¬ÔÝʱ²»Óò¿·Öϸ½Ú¡£³éÏó°üÀ¨Á½¸ö·½Ã棬һÊǹý³Ì³éÏ󣬶þÊÇÊý¾Ý³éÏó¡£
2. ¼Ì³Ð
¼Ì³ÐÊÇÒ»ÖÖÁª½áÀàµÄ²ã´ÎÄ£ÐÍ£¬²¢ÇÒÔÊÐíºÍ¹ÄÀøÀàµÄÖØÓã¬ËüÌṩÁË ......
Õý³£±àÒëÔËÐÐjavaÎļþ¿Ï¶¨Òª±¾µØÏÂÔØjdkºÍjre»òÕßʹÓü¯³ÉIDE(Eclipse,NetBeans)£¬Õâ¸öÍøÕ¾¸É´à½«±àÒ빤×÷·Åµ½·þÎñÆ÷ÉÏÈ¥£¬ÈÃÄã¿ÉÒÔÔÚÏß±àÒ룬
µÃ³ö´íÎóÐÅÏ¢£¬¸üÄѵõÄÊÇ»¹¿ÉÔËÐУ¬µ±È»²»ÄÜ×öͼÐκÍÎļþ²Ù×÷£¬ÒòΪËüÔËÐÐÔÚ·þÎñÆ÷¶Ë¡£
꿅᣼http://youjavait.com/
Ò³ÃæÉÏ·ÖΪÉÏÏÂÁ½¸öÃæ°å£¬ÓеãÀàËÆEclipse¡£±àÒëÊ ......