java»ñÈ¡µ±Ç°Â·¾¶[ת]
java»ñÈ¡µ±Ç°Â·¾¶[ת]
¹Ø¼ü×Ö: java ·¾¶
java »ñÈ¡µ±Ç°Â·¾¶
1 ¡¢ÀûÓà System.getProperty() º¯Êý»ñÈ¡µ±Ç°Â·¾¶£º
System.out.println(System.getProperty("user.dir"));//user.dir Ö¸¶¨Á˵±Ç°µÄ·¾¶
2 ¡¢Ê¹Óà File ÌṩµÄº¯Êý»ñÈ¡µ±Ç°Â·¾¶£º
File directory = new File("");// É趨Ϊµ±Ç°Îļþ¼Ð
try{
System.out.println(directory.getCanonicalPath());// »ñÈ¡±ê×¼µÄ·¾¶
System.out.println(directory.getAbsolutePath());// »ñÈ¡¾ø¶Ô·¾¶
}catch(Exceptin e){}
File.getCanonicalPath() ºÍ File.getAbsolutePath() ´óÔ¼Ö»ÊǶÔÓÚ new File(".") ºÍ new File("..") Á½ÖÖ·¾¶ÓÐËùÇø±ð¡£
# ¶ÔÓÚ getCanonicalPath() º¯Êý£¬“ ." ¾Í±íʾµ±Ç°µÄÎļþ¼Ð£¬¶ø” .. “Ôò±íʾµ±Ç°Îļþ¼ÐµÄÉÏÒ»¼¶Îļþ¼Ð
# ¶ÔÓÚ getAbsolutePath() º¯Êý£¬Ôò²»¹Ü” . ”¡¢“ .. ”£¬·µ»Øµ±Ç°µÄ·¾¶¼ÓÉÏÄãÔÚ new File() ʱÉ趨µÄ·¾¶
# ÖÁÓÚ getPath() º¯Êý£¬µÃµ½µÄÖ»ÊÇÄãÔÚ new File() ʱÉ趨µÄ·¾¶
±ÈÈ統ǰµÄ·¾¶Îª C:\test £º
File directory = new File("abc");
directory.getCanonicalPath(); // µÃµ½µÄÊÇ C:\test\abc
directory.getAbsolutePath(); // µÃµ½µÄÊÇ C:\test\abc
direcotry.getPath(); // µÃµ½µÄÊÇ abc
File directory = new File(".");
directory.getCanonicalPath(); // µÃµ½µÄÊÇ C:\test
directory.getAbsolutePath(); // µÃµ½µÄÊÇ C:\test\.
direcotry.getPath(); // µÃµ½µÄÊÇ .
File directory = new File("..");
directory.getCanonicalPath(); // µÃµ½µÄÊÇ C:\
directory.getAbsolutePath(); // µÃµ½µÄÊÇ C:\test\..
direcotry.getPath(); // µÃµ½µÄÊÇ ..
¹ØÓÚSystem.getProperty·½·¨µÄ²ÎÊý¼û
System.getProperty
Ïà¹ØÎĵµ£º
×î½üÔÚÔÛÃÇÕâ¸öÂÛ̳Àï×ÜÄÜ¿´¼û´ó¼ÒÌá³öÓÃjava´¦ÀíExcelµÄÎÊÌ⣬ÓÐʱ»¹Éæ¼°µ½Í¼ÐεÄÎÊÌ⣬
´ó¼Ò¿´ÁËÕâƪÎÄÕºó£¬ÎÒÏëÒ»¶¨»á½â¾ö²»ÉÙÈ˵ÄÎÊÌ⣡
¿´µ½ÍøÉϺܶàÎÄÕ¶¼Ò»Ö±¶¼ÊÇ˵POIµÄAPI²»ÄÜ´¦ÀíͼÐΣ¬Ò²¾ÍÊDz»ÄÜÍùExcelÀïÃæ¼ÓÈëͼÐΡ£
µ«ÊÂʵÉÏ£¬POI3.0³öÀ´Ö®ºó£¬Õâ¸öÎÊÌâÒѾ½â¾ö£¡ËùÒÔ˵£¬ÍùExcelÀïÃæ¼ÓÈëͼÐβ»±ØÒ»¶¨Ç ......
jar Ó¦Óà ÏÈ´ò¿ªÃüÁîÌáʾ·û(win2000»òÔÚÔËÐпðÀïÖ´ÐÐcmdÃüÁwin98ΪDOSÌáʾ·û)£¬ÊäÈëjar
-help,È»ºó»Ø³µ(Èç¹ûÄãÅÌÉÏÒѾÓÐÁËjdk1.1»òÒÔÉÏ°æ±¾)£¬¿´µ½Ê²Ã´£º
Ó÷¨£ºjar {ctxu}[vfm0Mi] [jar-Îļþ]
[manifest-Îļþ] [-C Ŀ¼] ÎļþÃû ...
Ñ¡Ï
-c ´´½¨ÐµĴ浵
-t Áгö´æµµÄÚÈݵÄÁбí
-x
Õ¹¿ª´æµµÖеÄÃüÃûµ ......
Ŀ ¼
1 ¼¯ºÏ¿ò¼Ü... 2
1.1 ¼¯ºÏ¿ò¼Ü¸ÅÊö... 2
1.1.1 ÈÝÆ÷¼ò½é... 2
1.1.2 ÈÝÆ÷µÄ·ÖÀà... 4
1.2 Collection. 5
1.2.1  ......
Ç°ÑÔ£ºÇ°¶Îʱ¼äÔÚCSDNµÄC++ÉçÇøÓöµ½Ò»¸öÐèÒª·â×°¿¼ÇÚ»ú½Ó¿ÚµÄ¶¯Ì¬¿â¸øJAVAµ÷ÓõÄÌû×Ó£¬¹´ÆðÁËÎÒ¶ÔJAVAµÄÎÞÏÞ»³Äî¡£ÔÚ´Ë£¬ÎÒÏë°ÑÕâÏî¼¼Êõ¼òµ¥ÔÙ½éÉÜһϡ£
Ò»¡¢¹ØÓÚJava Native Interface (JNI)
JNIÊÇJAVA±¾µØ±à³Ì½Ó¿Ú£¬ÊôÓÚJDKµÄÒ»²¿·Ö¡£ËüÔÊÐíJAVAÄܹ»²Ù×÷±¾µØAPI»òÓÉÆäËûÓïÑÔ±àдµÄ¶¯Ì¬¿â¡£²»¹ýµ±ÄãʹÓÃÕâÏî¼¼ÊõµÄʱºò£ ......
Java²»ÊÇÍêÃÀµÄ£¬JavaµÄ²»×ã³ýÁËÌåÏÖÔÚÔËÐÐËÙ¶ÈÉÏÒª±È´«Í³µÄC++ÂýÐí¶àÖ®Í⣬JavaÎÞ·¨Ö±½Ó·ÃÎʵ½²Ù×÷ϵͳµ×²ã£¨ÈçϵͳӲ¼þµÈ)£¬Îª´ËJavaʹÓÃnative·½·¨À´À©Õ¹Java³ÌÐòµÄ¹¦ÄÜ¡£
¡¡¡¡¿ÉÒÔ½«native·½·¨±È×÷Java³ÌÐòͬ£Ã³ÌÐòµÄ½Ó¿Ú£¬ÆäʵÏÖ²½Ö裺
¡¡¡¡£±¡¢ÔÚJavaÖÐÉùÃ÷native()·½·¨£¬È»ºó±àÒ룻
¡¡¡¡£²¡¢ÓÃjavah²úÉúÒ»¸ö.hÎ ......