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

javaÖеõ½µ±Ç°Â·¾¶µÄ·½·¨


¹éÄÉһЩÍøÉÏÈ¡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£¨""£©
µÃµ½µÄÒ²Êǵ±Ç°ClassPathµÄ¾ø¶ÔURI·¾¶¡£
È磺file£º/D£º/java/eclipse32/workspace/jbpmtest3/bin/
ÎÒÍƼöʹÓÃThread.currentThread£¨£©.getContextClassLoader£¨£©.getResource£¨""£©À´µÃµ½µ±Ç°µÄclasspathµÄ¾ø¶Ô·¾¶µÄURI±íʾ·¨¡£
ÔÚWebÓ¦ÓóÌÐòÖУ¬ÎÒÃÇÒ»°ãͨ¹ýServletContext.getRealPath£¨"/"£©·½·¨µÃµ½WebÓ¦ÓóÌÐòµÄ¸ùĿ¼µÄ¾ø¶Ô·¾¶¡£ÕâÑù£¬ÎÒÃÇÖ»ÐèÒªÌṩÏà¶ÔÓÚWebÓ¦ÓóÌÐò¸ùĿ¼µÄ·¾¶£¬¾Í¿ÉÒÔ¹¹½¨³ö¶¨Î»×ÊÔ´µÄ¾ø¶Ô·¾¶¡£
×¢Òâµã£º
1.¾¡Á¿²»ÒªÊ¹ÓÃÏà¶ÔÓÚSystem.getProperty£¨"user.dir"£©µ±Ç°Óû§Ä¿Â¼µÄÏà¶Ô·¾¶¡£ÕâÊÇÒ»¿Å¶¨Ê±Õ¨µ¯£¬Ëæʱ¿ÉÄÜÒªÄãµÄÃü¡£
2.¾¡Á¿Ê¹ÓÃURIÐÎʽµÄ¾ø¶Ô·¾¶×ÊÔ´¡£Ëü¿ÉÒÔºÜÈÝÒ×µÄת±äΪURI£¬URL£¬File¶ÔÏó¡£
3.¾¡Á¿Ê¹ÓÃÏà¶ÔclasspathµÄÏà¶Ô·¾¶¡£²»ÒªÊ¹Óþø¶Ô·¾¶¡£Ê¹ÓÃÉÏÃæClassLoaderUtilÀàµÄpublic static URL getExtendResource£¨String relativePath£©


Ïà¹ØÎĵµ£º

oracleµ÷ÓÃjava³ÌÐòÁ¬sqlserver2005

1¡¢ÔÚoracleµÄsys-sysdbaϵǽ
дһ¸öjava source³ÌÐòÁ´½Ósqlserver2005£º
create or replace and compile java source named test as
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class excutesql1
{
    public static String entry ......

RabbitÁ÷ÃÜÂëµÄJavaʵÏÖ

1. RabbitÁ÷ÃÜÂ루Rabbit Stream Cipher£©¼ò½é
      RabbitÁ÷ÃÜÂëÊÇÓÉCryptico¹«Ë¾£¨http://www.cryptico.com£©Éè¼ÆµÄ£¬ÃÜÔ¿³¤¶È128룬
×î´ó¼ÓÃÜÏûÏ¢³¤¶ÈΪ264 Bytes£¬¼´16 TB£¬ÈôÏûÏ¢³¬¹ý¸Ã³¤¶È£¬ÔòÐèÒª¸ü»»ÃÜÔ¿¶ÔʣϵÄÏûÏ¢½øÐд¦Àí¡£ËüÊÇÄ¿Ç°°²È«ÐԽϸߣ¬¼Ó/½âÃÜËٶȱȽϸßЧµÄÁ÷ÃÜÂëÖ®Ò»£ ......

¹ØÓÚJava¶ÁÈ¡xmlÎļþµÄѧϰ

Ò».javaÀà
package com.java.test;   
 
import org.w3c.dom.*;   
import javax.xml.parsers.*;   
import java.io.*;   
 
public class JavaReadXml {   
// Document¿ÉÒÔ¿´×÷ÊÇXMLÔÚÄÚ´æÖеÄÒ»¸ ......

JAVA¸ù¾ÝXML½Úµã¶ÁÈ¡XMLÎļþÄÚÈÝ

XMLÎļþ book.xml
<book>
<person>
<first>Kiran</first>
<last>Pai</last>
<age>22</age>
</person>
<person>
<first>Bill</first>
<last>Gates</last>
<age>46</age>
</person>
<person>
&l ......

¿ª²©——¡¾×ª¡¿JavaÖÐDAOµÄʵÏÖ

×î½üѧϰÖÐ×ÜÊǸоõÍ£Ö¹²»Ç°ÁË£¬µ½´ïÒ»¸öÆ¿¾±£¬¾­³£Ð´µ½Ò»¸öµØ·½»á¾õµÃÕâ¸ö¶«Î÷ѧ¹ýµ«Óв»ÊÇÄÇôµÄÇå³þ£¬Ò»ÖÖËƶ®·Ç¶®µÄ¸Ð¾õ£¬ËùÒÔ¾ö¶¨Õҵط½°ÑÿÌìËùѧϰµÄ»òÓÐÓõĶ«Î÷¼Ç¼ÏÂÀ´£¬½ñÌ쿪ʼÕâÀォÊÇÎҵļ¼Êõ¿â£¬ÎÒ»áÓëËùÓа®ºÃJAVAµÄÅóÓÑÒ»Æðѧϰ£¬Ò»Æð½ø²½¡£½ñÌìÊÇ¿ª²©µÚÒ»Ì죬ÕýºÃÔÚ¸´Ï°DAOÉè¼Æģʽ£¬¿´µ½Ò»Æ¬²»´íµÄ½²½â£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ