javaÖÐURLºÍFileµÄÏ໥ת»¯
Ê×ÏÈ£¬Ïë±È½ÏÒ»ÏÂÕâÁ½ÕߵIJ»Í¬¡£URLÓÃÓÚÍøÂ磬ËùÒÔ´øÓÐÃ÷ÏÔµÄprotocol£¬¶øÇÒ¶ÔÓÚÖÐÎļ°·ûºÅÖ§³ÖµÄºÜ²»ºÃ¡£File¾ÍÊÇÎÒÃÇÆ½³£ÏµÍ³ÖеÄÎļþ·¾¶ÁË£¬¶ÔÓÚÖÐÎļ°·ûºÅ¶¼Ö§³Ö£¬µ«ÊÇÒѾûÓÐprotocolÁË¡£ËùÒÔ£¬ËäÈ»Á½Õß¶¼¿ÉÒÔ±íʾÎļþ·¾¶£¬µ«ÊÇÈ´²»ÄÜ»ìÓÃÁË¡£
µäÐ͵ÄURLºÍFile·¾¶µÄ±È½Ï£º
URL£ºfile:/D:/my%20java/URL&FILE/%e5%9b%be%e7%89%87/tongji.jpg
File£ºD:\my java\URL&FILE\ͼƬ\tongji.jpg
ÆäʵÁ½ÕßÊÇÒ»¸öÎļþ¡£
»Øµ½ÕýÌ⣺
ÕâÊÇÎÒÔÚJDK5.0ÏÂÕÒµ½µÄ·½·¨£¬JDK5.0ÒÔϲ»Ö§³Ö£º
URL to File:
URL url=……;
File file=new File(url.toURI);
File to URL:
File file=……;
URL url=file.toURL();
++++++++++++++++++++++++++++
»ñÈ¡JAVA·¾¶£¬°üÀ¨CLASSPATHÍâµÄ·¾¶
¹éÄÉÒ»Ð©ÍøÉÏÈ¡JAVA·¾¶µÄ·½·¨£º
¡¡¡¡×¢Ã÷£ºÈç¹û´ÓANTÆô¶¯³ÌÐò£¬this.getClass().getResource("")È¡³öÀ´µÄ±È½Ï¹Ö£¬Ö±½ÓÓÃJAVAÃüÁîÐе÷ÊԾͿɳɹ¦¡£
¡¡¡¡
µÃµ½classpathºÍµ±Ç°ÀàµÄ¾ø¶Ô·¾¶µÄһЩ·½·¨
¡¡¡¡»ñµÃCLASSPATHÖ®Íâ·¾¶µÄ·½·¨£º
¡¡¡¡URL base = this.getClass().getResource(""); //ÏÈ»ñµÃ±¾ÀàµÄËùÔÚλÖã¬Èç/home/popeye/testjava/build/classes/net/
¡¡¡¡String path = new File(base.getFile(), "../../../"+name).getCanonicalPath(); //¾Í¿ÉÒԵõ½/home/popeye/testjava/name
¡¡¡¡ÏÂÃæÊÇһЩµÃµ½classpathºÍµ±Ç°ÀàµÄ¾ø¶Ô·¾¶µÄһЩ·½·¨¡£Äã¿ÉÄÜÐèҪʹÓÃÆäÖеÄһЩ·½·¨À´µÃµ½ÄãÐèÒªµÄ×ÊÔ´µÄ¾ø¶Ô·¾¶¡£
¡¡¡¡1.FileTest.class.getResource("")
¡¡¡¡µÃµ½µÄÊǵ±Ç°ÀàFileTest.classÎļþµÄURIĿ¼¡£²»°üÀ¨×Ô¼º£¡
¡¡¡¡È磺file:/D:/java/eclipse32/workspace/jbpmtest3/bin/com/test/
¡¡¡¡2.FileTest.class.getResource("/")
¡¡¡¡µÃµ½µÄÊǵ±Ç°µÄclasspathµÄ¾ø¶ÔURI·¾¶¡£
¡¡¡¡È磺file:/D:/java/eclipse32/workspace/jbpmtest3/bin/
¡¡¡¡3.Thread.currentThread().getContextClassLoader().getResource("")
¡¡¡¡µÃµ½µÄÒ²Êǵ±Ç°ClassPathµÄ¾ø¶ÔURI·¾¶¡£
¡¡¡¡È磺file:/D:/java/eclipse32/workspace/jbpmtest3/bin/
¡¡¡¡4.FileTest.class.getClassLoader().getResource("")
¡¡¡¡µÃµ½µÄÒ²Êǵ±Ç°ClassPathµÄ¾ø¶ÔURI·¾¶¡£
¡¡¡¡È磺file:/D:/java/eclipse32/workspace/jbpmtest3/bin/
¡¡¡¡5.ClassLoader.getSystemResource("
Ïà¹ØÎĵµ£º
public static void getConnAndTableStruct() {
Connection connection = null;
PreparedStatement pstmt = null;
ResultSetMetaData rsmd = null;
try {
// mysqlÁ¬½Ó
//Class.forName("org.gjt.mm.mysql.Driver");
//connection = DriverManager.g ......
http://babyjoycry.javaeye.com/blog/587527
1. import info.monitorenter.cpdetector.io.CodepageDetectorProxy;
2. import info.monitorenter.cpdetector.io.HTMLCodepageDetector;
3. import info.monitorenter.cpdetector.io.JChardetFacade;
4.
5. import java.io.BufferedReader;
......
ÕâÊÇÒ»¸öÓÃJAVA W3C DOM ½øÐÐXML²Ù×÷µÄÀý×Ó£¬°üº¬Á˲éѯ¡¢Ôö¼Ó¡¢Ð޸ġ¢É¾³ý¡¢±£´æµÄ»ù±¾²Ù×÷¡£½ÏÍêÕûµÄÃèÊöÁËÒ»¸öXMLµÄÕû¸ö²Ù×÷Á÷³Ì¡£ÊʺϸÕÈëÃÅJAVA XML²Ù×÷µÄÅóÓѲο¼ºÍѧϰ¡£
¼ÙÉèÓÐXMLÎļþ£ºtest1.xml
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book>
<name>¹þÀï²¨Ì ......
¹«Ë¾Vac·½·¨¹ýÂËÆ÷ʹÓõ½·´Éä»úÖÆ£¬¶ÁÈ¡xmlÅäÖÃÎļþ¹ýÂËÓû§·ÃÎʵķ½·¨ÃûÊÇ·ñºÏ·¨¡£
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRe ......
1 . 1 2 . 1 ²»ÒªÃÔʧ
ÔÚÕû¸ö¿ª·¢¹ý³ÌÖУ¬×îÖØÒªµÄÊÂÇé¾ÍÊÇ£º²»Òª½«×Ô¼ºÃÔʧ£¡µ«ÊÂʵÉÏÕâÖÖÊÂÇéºÜÈÝÒ×·¢Éú¡£´ó¶àÊý·½·¨¶¼Éè
¼ÆÓÃÀ´½â¾ö×î´ó·¶Î§ÄÚµÄÎÊÌâ¡£µ±È»£¬Ò²´æÔÚÒ»Ð©ÌØ±ðÀ§ÄѵÄÏîÄ¿£¬ÐèÒª×÷Õ߸¶³ö¸üΪ¼èÐÁµÄŬÁ¦£¬»òÕ߸¶
³ö¸ü´óµÄ´ú¼Û¡£µ«ÊÇ£¬´ó¶àÊýÏîÄ¿¶¼ÊDZȽϓ³£¹æ”µÄ£¬ËùÒÔÒ»°ã¶¼ÄÜ×÷³ö³É¹¦µÄ·ÖÎö ......