Java¶ÁÈ¡Îļþ(ÒÔºó¼ÌÐøÌí¼Ó)
package cf.java.study.java.io;
import java.io.File;
import java.io.FileInputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class FileTests {
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Before
public void startTest() {
System.out.println(" Test Start " + StringUtils.repeat("-", 10));
}
@After
public void endTest() {
System.out.println('\n' + StringUtils.repeat("-", 10) + " Test End \n");
}
@Test
public void readDir() throws Exception {
File file = new File("/");
System.out.println("file: \n" + file);
// list the items in the directory
for (String str : file.list()) {
System.out.println(str);
}
}
@Test
public void readFile() throws Exception {
File file = new File("./test");
// make a FileInputStream with the file instance
FileInputStream fis = new FileInputStream(file);
// read the bytes from fis
// it is the end of file when read() returns -1
for (int re = 0; re >= 0; re = fis.read()) {
System.out.print((char)re);
}
fis.close();
}
@Test
public void readFileByApache() throws Exception {
// are you crazy?? can you be more simplier?
System.out.print(FileUtils.readFileToString(new File("./test")));
}
}
Ïà¹ØÎĵµ£º
1£® Ô¤ÏȼÓÔØÓëÒÀÐèÇó¼ÓÔØ
Java ÔËÐл·¾³ÎªÁËÓÅ»¯ÏµÍ³£¬Ìá¸ß³ÌÐòµÄÖ´ÐÐËٶȣ¬ÔÚ JRE ÔËÐеĿªÊ¼»á½« Java ÔËÐÐËùÐèÒªµÄ»ù±¾Àà²ÉÓÃÔ¤ÏȼÓÔØ£¨
pre-loading £©µÄ·½·¨È«²¿¼ÓÔØÒªÄÚ´æµ±ÖУ¬ÒòΪÕâЩµ¥ÔªÔÚ Java ³ÌÐòÔËÐеĹý³Ìµ±Öо³£ÒªÊ¹Óõģ¬Ö÷Òª°üÀ¨ JRE µÄ
rt.jar ÎļþÀïÃæËùÓÐµÄ .class ÎÄ ......
ö¾ÙÀàÐÍÊÇJDK5.0µÄÐÂÌØÕ÷¡£SunÒý½øÁËÒ»¸öȫеĹؼü×ÖenumÀ´¶¨ÒåÒ»¸öö¾ÙÀà¡£ÏÂÃæ¾ÍÊÇÒ»¸öµäÐÍö¾ÙÀàÐ͵Ķ¨Ò壺
Java´úÂë
public enum Color{
RED,BLUE,BLACK,YELLOW,GREEN
}
public enum Color{
RED,BLUE,BLACK,YELLOW,GREEN
}
ÏÔ ......
¼ÆËãÒ»ÏÂʱ¼ä£¡ÎÒ¿ªÊ¼Ñ§Ï°JAVA±à³ÌÒѾÁ½¸öÔÂÁË£¬Ã¿½Ú¿Î¶¼ÊÇÔÚѧϰһÏÂÀíÂ۵Ķ«Î÷¡£¸Ð¾õÉÏûɶÓô¦Ò»Ñù£¬ËùÒÔ×Ô¼º×ÅÊÖ×öһЩ¼òµ¥µÄJAVA±à³Ì¡£µÚÒ»´Î±à³Ì¿Ï¶¨Ã»·¨¸ú´óʦÃDZȽÏÁË£¬µ«ÊÇÕâÒ²¼ûÖ¤ÁËÎÒŬÁ¦µÄ½á¹û£¡
import java.awt.*;
import java.awt.event.*;
import java.util.Date;
import javax.swing.JPassword ......
°ÑÊ÷ÐεĽṹ³éÏóÁËһϡ£
ITree
package utility.structure.def;
/**
*
* @author odie.tang
*
* @version 1.0 10/30/09
*/
public interface ITree<E>{
E getData();
E remove();
void setData(E e);
int getDepth();
int getLevel();
ITree<E> getRoot();
......
Javaѧϰ·¾¶£¨Ò»£©¹¤¾ßƪ
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJDKÊÇSun¹«Ë¾·¢²¼µÄJDK£¬³ýÁËSunÖ®Í⣬»¹Óкܶ๠......