Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÓÃjava¶ÁÎļþÄÚÈÝ

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.io.Reader;
/**
 *
 * ¶àÖÖ·½Ê½¶ÁÎļþÄÚÈÝ¡£
 *
 * 1¡¢°´×Ö½Ú¶ÁÈ¡ÎļþÄÚÈÝ 2¡¢°´×Ö·û¶ÁÈ¡ÎļþÄÚÈÝ 3¡¢°´ÐжÁÈ¡ÎļþÄÚÈÝ 4¡¢Ëæ»ú¶ÁÈ¡ÎļþÄÚÈÝ
 *
 */
public class ReadfromFile
{
    /**
     * ÒÔ×Ö½ÚΪµ¥Î»¶ÁÈ¡Îļþ£¬³£ÓÃÓÚ¶Á¶þ½øÖÆÎļþ£¬ÈçͼƬ¡¢ÉùÒô¡¢Ó°ÏñµÈÎļþ¡£
     *
     * @param fileName
     *                ÎļþµÄÃû
     */
    public static void readFileByBytes(String fileName)
    {
 File file = new File(fileName);
 InputStream in = null;
 try
 {
     System.out.println("ÒÔ×Ö½ÚΪµ¥Î»¶ÁÈ¡ÎļþÄÚÈÝ£¬Ò»´Î¶ÁÒ»¸ö×Ö½Ú£º");
     // Ò»´Î¶ÁÒ»¸ö×Ö½Ú
     in = new FileInputStream(file);
     int tempbyte;
     while ((tempbyte = in.read()) != -1)
     {
  System.out.write(tempbyte);
     }
     in.close();
 }
 catch (IOException e)
 {
     e.printStackTrace();
     return;
 }
 try
 {
     System.out.println("ÒÔ×Ö½ÚΪµ¥Î»¶ÁÈ¡ÎļþÄÚÈÝ£¬Ò»´Î¶Á¶à¸ö×Ö½Ú£º");
     // Ò»´Î¶Á¶à¸ö×Ö½Ú
     byte[] tempbytes = new byte[100];
     int byteread = 0;
     in = new FileInputStream(fileName);
     ReadfromFile.showAvailableBytes(in);
     // ¶ÁÈë¶à¸ö×Ö½Úµ½×Ö½ÚÊý×


Ïà¹ØÎĵµ£º

JavaÖÐÖØÔغÍÖØдµÄÇø±ð

1¡¢ÖØÔØ(Overloading)
£¨1£©·½·¨ÖØÔØÊÇÈÃÀàÒÔͳһµÄ·½Ê½´¦Àí²»Í¬ÀàÐÍÊý¾ÝµÄÒ»ÖÖÊֶΡ£¶à¸öͬÃûº¯Êýͬʱ
´æÔÚ£¬¾ßÓв»Í¬µÄ²ÎÊý¸öÊý/ÀàÐÍ¡£ÖØÔØOverloadingÊÇÒ»¸öÀàÖжà̬ÐÔµÄÒ»ÖÖ±íÏÖ¡£
£¨2£©JavaµÄ·½·¨ÖØÔØ£¬¾ÍÊÇÔÚÀàÖпÉÒÔ´´½¨¶à¸ö·½·¨£¬ËüÃǾßÓÐÏàͬµÄÃû×Ö£¬µ«¾ß
Óв»Í¬µÄ²ÎÊýºÍ²»Í¬µÄ¶¨Òå¡£µ÷Ó÷½·¨Ê±Í¨¹ý´«µÝ¸øËüà ......

Ìá¸ßjava¿ª·¢Ëٶȣ¨Eclipse¿ì½Ý¼üÓ¦Óã©

ÏëÔÚ¿ª·¢ÖÐÌá¸ßËٶȺÍЧÂÊ£¡²»ÄÜÍü¼ÇµÄEclipse¿ì½Ý¼ü
Eclipse¿ì½Ý¼ü´óÈ«
ÍƼöCtrl+1 ¿ìËÙÐÞ¸´(×î¾­µäµÄ¿ì½Ý¼ü,¾Í²»Óöà˵ÁË)
Ctrl+D: ɾ³ýµ±Ç°ÐÐ
Ctrl+Alt+↓ ¸´ÖƵ±Ç°Ðе½ÏÂÒ»ÐÐ(¸´ÖÆÔö¼Ó)
Ctrl+Alt+↑ ¸´ÖƵ±Ç°Ðе½ÉÏÒ»ÐÐ(¸´ÖÆÔö¼Ó)
Alt+↓ µ±Ç°ÐкÍÏÂÃæÒ»Ðн»»¥Î»ÖÃ(ÌرðʵÓÃ,¿ÉÒÔÊ¡È¥ÏȼôÇÐ,ÔÙÕ³Ìù ......

java¼¼ÄÜ°ÙÁ¶001 Test

package CH1;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class exercise001 extends JApplet {
 // ¶¨Òå±äÁ¿
 private JColorChooser chooser = new JColorChooser();
 private JButton button = new JButton("Show Color Chooser");
 private JDialog dialo ......

java¶àÏß³ÌʹÓÃSynchronized¹Ø¼ü×Öͬ²½Àà·½

ÒªÏë½â¾ö“ÔàÊý¾Ý”µÄÎÊÌ⣬×î¼òµ¥µÄ·½·¨¾ÍÊÇʹÓÃsynchronized¹Ø¼ü×ÖÀ´Ê¹run·½·¨Í¬²½£¬´úÂëÈçÏ£º
public synchronized void run()
{
 
}
´ÓÉÏÃæµÄ´úÂë¿ÉÒÔ¿´³ö£¬Ö»ÒªÔÚvoidºÍpublicÖ®¼ä¼ÓÉÏsynchronized¹Ø¼ü×Ö£¬¾Í¿ÉÒÔʹrun·½·¨Í¬²½£¬Ò²¾ÍÊÇ˵£¬¶ÔÓÚͬһ¸öJavaÀàµÄ¶ÔÏóʵÀý£¬run·½·¨Í¬ ......

java byteÓëchar»¥×ªÔ­Àí ת

Ò»¡¢×Ö½ÚºÍunicode
JavaÄÚºËÊÇunicodeµÄ£¬¾ÍÁ¬classÎļþÒ²ÊÇ£¬µ«ÊǺܶàýÌ壬°üÀ¨Îļþ/Á÷µÄ±£´æ·½Ê½ÊÇʹÓÃ×Ö½ÚÁ÷µÄ¡£Òò´ËJavaÒª¶ÔÕâЩ×Ö½ÚÁ÷¾­ÐÐת»¯¡£ charÊÇunicodeµÄ£¬¶øbyteÊÇ×Ö½Ú¡£JavaÖÐ byte/char»¥×ªµÄº¯ÊýÔÚsun.ioµÄ°üÖмäÓС£ÆäÖÐByteToCharConverterÀàÊÇÖе÷¶È£¬¿ÉÒÔÓÃÀ´¸æËßÄ㣬ÄãÓÃµÄ convertor¡£ÆäÖÐÁ½¸öºÜ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ