¶ÁÎļþ£¨java£©
ʹÓÃJava²Ù×÷Îı¾ÎļþµÄ·½·¨Ïê½â
ÕªÒª: ×î³õjavaÊDz»Ö§³Ö¶ÔÎı¾ÎļþµÄ´¦ÀíµÄ£¬ÎªÁËÃÖ²¹Õâ¸öȱº¶¶øÒýÈëÁËReaderºÍWriterÁ½¸öÀ࣬ÕâÁ½¸öÀ඼ÊdzéÏóÀ࣬WriterÖÐ write(char[] ch,int off,int
length)£¬flush()ºÍclose()·½·¨Îª³éÏó·½·¨£¬ReaderÖÐread(char[] ch,int off,int length)ºÍclose()·½·¨ÊdzéÏó·½·¨¡£×ÓÀàÓ¦¸Ã·Ö±ðʵÏÖËûÃÇ¡£ µ±ÎÒÃǶÁдÎı¾ÎļþµÄʱºò£¬²ÉÓÃReaderÊǷdz£·½±ãµÄ£¬±ÈÈçFileReader£¬InputStreamReaderºÍBufferedReader¡£ÆäÖÐ×îÖØÒªµÄÀàÊÇInputStreamReader£¬ËüÊÇ×Ö½Úת»»Îª×Ö·ûµÄÇÅÁº¡£Äã¿ÉÒÔÔÚ¹¹ÔìÆ÷ÖØÖ¸¶¨±àÂëµÄ·½Ê½£¬Èç¹û²»Ö¸¶¨µÄ»°½«²ÉÓõײã²Ù×÷ϵͳµÄĬÈϱàÂ뷽ʽ£¬ÀýÈçGBKµÈ¡£µ±Ê¹ÓÃFileReader¶ÁÈ¡ÎļþµÄʱºò¡£FileReader fr = new FileReader("ming.txt");
int ch = 0;
while((ch = fr.read())!=-1 )
{
System.out.print((char)ch);
}
ÆäÖÐread()·½·¨·µ»ØµÄÊǶÁÈ¡µÃϸö×Ö·û¡£µ±È»ÄãÒ²¿ÉÒÔʹÓÃread(char[] ch,int off,int length)ÕâºÍ´¦Àí¶þ½øÖÆÎļþµÄʱºòÀàËÆ£¬²»¶à˵ÁË¡£Èç¹ûʹÓÃInputStreamReaderÀ´¶ÁÈ¡ÎļþµÄʱºòwhile((ch = isr.read())!=-1)
{
System.out.print((char)ch);
}
ÕâºÍFileReader²¢Ã»ÓÐʲôÇø±ð£¬ÊÂʵÉÏÔÚFileReaderÖеķ½·¨¶¼ÊÇ´ÓInputStreamReaderÖм̳йýÀ´µÄ¡£read()·½·¨ÊDZȽϺ÷Ñʱ¼äµÄ£¬Èç¹ûΪÁËÌá¸ßЧÂÊÎÒÃÇ¿ÉÒÔʹÓÃBufferedReader¶ÔReader½øÐаü×°£¬ÕâÑù¿ÉÒÔÌá¸ß¶ÁÈ¡µÃËٶȣ¬ÎÒÃÇ¿ÉÒÔÒ»ÐÐÒ»ÐеĶÁÈ¡Îı¾£¬Ê¹ÓÃreadLine()·½·¨¡£BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("ming.txt")));
String data = null;
while((data = br.readLine())!=null)
{
System.out.println(data);
}
µ±ÄãÃ÷°×ÁËÈçºÎÓÃReaderÀ´¶ÁÈ¡Îı¾ÎļþµÄʱºòÄÇôÓÃWriterдÎļþͬÑù·Ç³£¼òµ¥¡£ÓÐÒ»µãÐèҪעÒ⣬µ±ÄãдÎļþµÄʱºò£¬ÎªÁËÌá¸ßЧÂÊ£¬Ð´ÈëµÄÊý¾Ý»áÏÈ·ÅÈ뻺³åÇø£¬È»ºóдÈëÎļþ¡£Òò´ËÓÐʱºòÄãÐèÒªÖ÷¶¯µ÷ÓÃflush()·½·¨¡£ÓëÉÏÃæ¶ÔÓ¦µÄдÎļþµÄ·½·¨Îª£º
FileWriter fw = new FileWriter("hello.txt");
String s = "hello world";
fw.write(s,0,s.length());
fw.flush();OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("hello2.txt"));
osw.write(s,0,s.length());
osw.flush();PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream("hello3.txt")),true);
pw.println(s);
²»ÒªÍü¼ÇÓÃÍêºó¹Ø±ÕÁ
Ïà¹ØÎĵµ£º
ÔÚËùÓÐ×é¼þ¶¼·Åµ½JFrameÖ®ºó£¬ÏÈsetSize()£¬È»ºóÔÙsetVisible() ¡£
ÉèÖÃÁË´°¿ÚµÄSize,²¼¾Ö¹ÜÀíÆ÷²ÅÄÜΪ¸÷¸ö×é¼þ°²ÅźÏÊʵÄλÖÃ,Ö®ºóÔÙ°Ñ´°ÌåÏÔʾ³öÀ´setVisible()£¬±ÈÈçÄ㻹²»ÖªµÀ³§·¿µÄ´óС£¬Õâʱ¾ÍÎÞ·¨¾ö¶¨É豸°²·ÅµÄλÖᣠ......
1. Ñ»·listÖеÄËùÓÐÔªËØÈ»ºóɾ³ýÖظ´
public static List removeDuplicate(List list) {
for ( int i = 0 ; i < list.size() - 1 ; i ++ ) {
for ( int j = list.size() - 1 ; j > i; j -- ) {
if (list.get(j).equals(list.get(i))) {
......
ÎÒ½ñÌìѧϰÁËÐìÀÏʦ½²µÄSpring֪ʶ£¬ÎÒ×öÁ˼òµ¥µÄ±Ê¼Ç£º
·´Ïò¿ØÖÆ(IOC)
£º
bean¹¤³§:×î¼òµ¥µÄÈÝÆ÷£¬ÌṩÁË»ù´¡µÄÒÀÀµ×¢ÈëÖ§³Ö¡£´´½¨¸÷ÖÖÀàÐ͵ÄBean.
Ó¦ÓÃÉÏÏÂÎÄ:½¨Á¢ÔÚbean¹¤³§»ù´¡Ö®ÉÏ£¬Ìṩϵͳ¼Ü¹¹·þÎñ¡£
ClassPathXmlApplicationContext:´ÓÀà·¾¶ÖмÓÔØ¡£
FileSystemXmlAp ......
תÌû×Ô http://www.javaeye.com/topic/257191
javaÖÐhashcode()ºÍequals()µÄÏê½â
1. Ê×ÏÈequals()ºÍhashcode()ÕâÁ½¸ö·½·¨¶¼ÊÇ´ÓobjectÀàÖм̳йýÀ´µÄ¡£
equals()·½·¨ÔÚobjectÀàÖж¨ÒåÈçÏ£º
public boolean equals(Object obj) {
return (this == obj);
}
ºÜÃ÷ÏÔÊǶÔÁ½¸ö¶ÔÏóµÄµØÖ·Öµ½øÐеıȽϣ¨¼´±È½Ï ......