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

JavaÏà¶Ô·¾¶¶ÁÈ¡Îļþ


²»¹ÜÄãÊÇÐÂÊÖ»¹ÊÇÀÏÄñ£¬ÔÚ³ÌÐòÖжÁÈ¡×ÊÔ´Îļþ×Ü»áÓöµ½Ò»Ð©ÕÒ²»µ½ÎļþµÄÎÊÌ⣬ÕâÓëJavaµ×²ãµÄʵÏÖÓйأ¬²»ÄÜËãbug£¬Ö»Òª·½·¨µÃµ±£¬ÎÊÌ⻹ÊÇ¿ÉÒÔ½â¾öµÄ¡£
 
ÏîÄ¿µÄÎļþ¼Ð½á¹¹£º
repathtest 
©À©¤src 
©¦    ©¸©¤com 
©¦            ©¸©¤lavasoft 
©¦                    ©À©¤test 
©¦                    ©¸©¤res 
©À©¤doc
 
 
 
1¡¢ÔÚJava¿ª·¢¹¤¾ßµÄprojectÖÐʹÓÃÏà¶Ô·¾¶
ÔÚprojectÖУ¬Ïà¶Ô·¾¶µÄ¸ùĿ¼ÊÇprojectµÄ¸ùÎļþ¼Ð£¬Ôڴ˾ÍÊÇrepathtestÎļþ¼ÐÁË¡£
´´½¨ÎļþµÄд·¨ÊÇ£º
File f = new File("src/com/lavasoft/res/a.txt");
 
File f = new File("doc/b.txt");
 
×¢Ò⣺
·¾¶²»ÒÔ“/”¿ªÍ·£»
ÍÑÀëÁËIDE»·¾³£¬Õâ¸öд·¨¾ÍÊÇ´íÎóµÄ£¬Ò²²¢·Çÿ¸öIDE¶¼Èç´Ë£¬µ«ÎÒ¼ûµ½µÄ¶¼ÊÇÕâÑùµÄ¡£
 
2¡¢Í¨¹ýCLASSPATH¶ÁÈ¡°üÄÚÎļþ
¶ÁÈ¡°üÄÚÎļþ£¬Ê¹ÓõÄ·¾¶Ò»¶¨ÊÇÏà¶ÔµÄclasspath·¾¶£¬±ÈÈça£¬Î»ÓÚ°üÄÚ£¬´Ëʱ¿ÉÒÔ´´½¨¶ÁÈ¡aµÄ×Ö½ÚÁ÷£º
InputStream in = ReadFile.class.getResourceAsStream("/com/lavasoft/res/a.txt");
ÓÐÁË×Ö½ÚÁ÷£¬¾ÍÄܶÁÈ¡µ½ÎļþÄÚÈÝÁË¡£
 
×¢Ò⣺
ÕâÀï±ØÐëÒÔ“/”¿ªÍ·£»
 
3¡¢¿´¿´ÍêÕûµÄ²âÊÔ´úÂë
package com.lavasoft.test; 
import java.io.*; 
/** 
* Java¶ÁÈ¡Ïà¶Ô·¾¶µÄÎļþ 

* @author leizhimin 2010-1-15 10:59:43 
*/ 
public class ReadFile { 
        public static void main(String[] args) { 
                readTextA_ByClassPath(); 
                readTextA_ByProjectRelativePath(); 
       &n


Ïà¹ØÎĵµ£º

java½Ó¿ÚºÍ³éÏóÀàµÄÇø±ð

¼òµ¥À´Ëµ£¬ ½Ó¿ÚÊǹ«¿ªµÄ£¬ÀïÃæ²»ÄÜÓÐ˽Óеķ½·¨»ò±äÁ¿£¬ÊÇÓÃÓÚÈñðÈËʹÓõģ¬¶ø³éÏóÀàÊÇ¿ÉÒÔÓÐ˽Óз½·¨»ò˽ÓбäÁ¿µÄ£¬ÁíÍ⣬ʵÏÖ½Ó¿ÚµÄÒ»¶¨ÒªÊµÏÖ½Ó¿ÚÀﶨÒåµÄËùÓз½·¨£¬¶øʵÏÖ³éÏóÀà¿ÉÒÔÓÐÑ¡ÔñµØÖØдÐèÒªÓõ½µÄ·½·¨¡£
Ò»°ãµÄÓ¦ÓÃÀ×¼¶µÄÊǽӿڣ¬È»ºóÊdzéÏóÀàʵÏÖ½Ó¿Ú£¬×îºó²Åµ½¾ßÌåÀàʵÏÖ¡£
»¹ÓУ¬½Ó¿Ú¿ÉÒÔʵÏÖ¶àÖ ......

ÈçºÎÓÃjavaAPIÈ¡µÃjava½ø³ÌµÄPID£¿

ûÓÐÒ»¸öƽ̨¶ÀÁ¢µÄ·½·¨Äܹ»ÔÚËùÓеÄJVMÉÏʵÏÖ¡£Ò»¸ö×î¼òµ¥¡¢×î½Ó½üÈ¡µÃPIDµÄ°ì·¨ÊÇʹÓãº
ManagementFactory.getRuntimeMXBean().getName() ¡£
È¡µÃµ½µÄ×Ö·û´ÜµÄ¸ñʽΪ[PROCESS_ID]@[MACHINE_NAME]£¬Í¨¹ý½âÎöÕâ¸ö×Ö·û´®¾Í¿ÉÒԵõ½java½ø³ÌµÄPID¡£
ÔÚÒÔÏÂƽ̨ÉϲâÊÔͨ¹ý£º
1¡¢Windows¡¢LinuxÉϵÄSun JDK1.5¡¢JDK6
2¡¢H ......

java±àÂë¹æ·¶_¿Õ°×ºÍÃüÃû¹æ·¶

1.       ¿Õ°×(White Space)
7.1  ¿ÕÐÐ(Blank Lines)
¿ÕÐн«Âß¼­Ïà¹ØµÄ´úÂë¶Î·Ö¸ô¿ª£¬ÒÔÌá¸ß¿É¶ÁÐÔ¡£ÏÂÁÐÇé¿öÓ¦¸Ã×ÜÊÇʹÓÃÁ½¸ö¿ÕÐУº
·Ò»¸öÔ´ÎļþµÄÁ½¸öƬ¶Î(section)Ö®¼ä
·ÀàÉùÃ÷ºÍ½Ó¿ÚÉùÃ÷Ö®¼ä
ÏÂÁÐÇé¿öÓ¦¸Ã×ÜÊÇʹÓÃÒ»¸ö¿ÕÐУº
·Á½¸ö·½·¨Ö®¼ä
··½ ......

ÔËÐÐʱʵÏÖJavaµÄ¶à̬ÐÔ

     ÔËÐÐʱ¶à̬ÐÔÊÇÃæÏò¶ÔÏó³ÌÐòÉè¼Æ´úÂëÖØÓõÄÒ»¸ö×îÇ¿´ó»úÖÆ£¬¶¯Ì¬ÐԵĸÅÄîÒ²¿ÉÒÔ±»Ëµ³É“Ò»¸ö½Ó¿Ú£¬¶à¸ö·½·¨”¡£JavaʵÏÖÔËÐÐʱ¶à̬ÐԵĻù´¡ÊǶ¯Ì¬·½·¨µ÷¶È£¬ËüÊÇÒ»ÖÖÔÚÔËÐÐʱ¶ø²»ÊÇÔÚ±àÒëÆÚµ÷ÓÃÖØÔØ·½·¨µÄ»úÖÆ£¬ÏÂÃæ¾Í¼Ì³ÐºÍ½Ó¿ÚʵÏÖÁ½·½Ãæ̸̸javaÔËÐÐʱ¶à̬ÐÔµÄʵÏÖ¡£
¡¡¡¡Ò»¡¢Í¨¹ý ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ