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
Ïà¹ØÎĵµ£º
http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp
Categories of Java HotSpot VM Options
Standard options recognized by the Java HotSpot VM are described on the Java Application Launcher reference pages for Windows
, Solaris
and Linux
. This document deals exclusively wit ......
System.out.println(2|0); //0010 0000 =>0010 = 2
System.out.println(2|1); //0010 0001 =>0011 = 3
System.out.println(3|2); //0011 0010 =>0011 = 3
System.out.println(3&2); //0011 0010 =>0010 = 2
/*
ÔÚjavaÖÐ0´ú±í¼Ù, 1´ú±íÕæ
00011|0010 ´ÓÓÒµ½×ó±È½Ï0|1 = 1, 1|0 = ......
1¡¢Oracle8/8i/9iÊý¾Ý¿â£¨thinģʽ£©
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orclΪÊý¾Ý¿âµÄSID
String user="test";
String password="test";
Connection conn= DriverManager.getC ......
/************************************************************************
* & ......
Java²»ÊÇÍêÃÀµÄ£¬JavaµÄ²»×ã³ýÁËÌåÏÖÔÚÔËÐÐËÙ¶ÈÉÏÒª±È´«Í³µÄC++ÂýÐí¶àÖ®Í⣬JavaÎÞ·¨Ö±½Ó·ÃÎʵ½²Ù×÷ϵͳµ×²ã£¨ÈçϵͳӲ¼þµÈ)£¬Îª´ËJavaʹÓÃnative·½·¨À´À©Õ¹Java³ÌÐòµÄ¹¦ÄÜ¡£
¡¡¡¡¿ÉÒÔ½«native·½·¨±È×÷Java³ÌÐòͬ£Ã³ÌÐòµÄ½Ó¿Ú£¬ÆäʵÏÖ²½Ö裺
¡¡¡¡£±¡¢ÔÚJavaÖÐÉùÃ÷native()·½·¨£¬È»ºó±àÒ룻
¡¡¡¡£²¡¢ÓÃjavah²úÉúÒ»¸ö.hÎ ......