20¸ö·Ç³£ÓÐÓõÄJava³ÌÐòƬ¶Î
1. ×Ö·û´®ÓÐÕûÐ͵ÄÏ໥ת»»
¡¡¡¡Java´úÂë
¡¡¡¡String a = String.valueOf(2); //integer to numeric string
¡¡¡¡int i = Integer.parseInt(a); //numeric string to an int
¡¡¡¡2. ÏòÎļþĩβÌí¼ÓÄÚÈÝ
¡¡¡¡Java´úÂë
¡¡¡¡BufferedWriter out = null;
¡¡¡¡try {
¡¡¡¡out = new BufferedWriter(new FileWriter(”filename”, true));
¡¡¡¡out.write(”aString”);
¡¡¡¡} catch (IOException e) {
¡¡¡¡// error processing code
¡¡¡¡} finally {
¡¡¡¡if (out != null) {
¡¡¡¡out.close();
¡¡¡¡}
¡¡¡¡}
¡¡¡¡3. µÃµ½µ±Ç°·½·¨µÄÃû×Ö
¡¡¡¡Java´úÂë
¡¡¡¡String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
¡¡¡¡4. ת×Ö·û´®µ½ÈÕÆÚ
¡¡¡¡Java´úÂë
¡¡¡¡java.util.Date = java.text.DateFormat.getDateInstance().parse(date String);
¡¡¡¡»òÕßÊÇ£º
¡¡¡¡SimpleDateFormat format = new SimpleDateFormat( "dd.MM.yyyy" );
¡¡¡¡Date date = format.parse( myString );
¡¡¡¡5. ʹÓÃJDBCÁ´½ÓOracle
¡¡¡¡Java´úÂë
¡¡¡¡public class OracleJdbcTest
¡¡¡¡{
¡¡¡¡String driverClass = "oracle.jdbc.driver.OracleDriver";
¡¡¡¡Connection con;
¡¡¡¡public void init(FileInputStream fs) throws ClassNotFoundException, SQLException, FileNotFoundException, IOException
¡¡¡¡{
¡¡¡¡Properties props = new Properties();
¡¡¡¡props.load(fs);
¡¡¡¡String url = props.getProperty("db.url");
¡¡¡¡String userName = props.getProperty("db.user");
¡¡¡¡String password = props.getProperty("db.password");
¡¡¡¡Class.forName(driverClass);
¡¡¡¡con=DriverManager.getConnection(url, userName, password);
¡¡¡¡}
¡¡¡¡public void fetch() throws SQLException, IOException
¡¡¡¡{
¡¡¡¡PreparedStatement ps = con.prepareStatement("select SYSDATE from dual");
¡¡¡¡ResultSet rs = ps.executeQuery();
¡¡¡¡while (rs.next())
¡¡¡¡{
¡¡¡¡// do the thing you do
¡¡¡¡}
¡¡¡¡rs.close();
¡¡¡¡ps.close();
¡¡¡¡}
¡¡¡¡public static void main(String[] args)
¡¡¡¡{
¡¡¡¡OracleJdbcTest test = new OracleJdbcTest();
¡¡¡¡test.init();
¡¡¡¡test.fetch();
¡¡¡¡}
¡¡¡¡}
6. °Ñ Java util.Date ת³É sql.Date
¡¡¡¡Java´úÂë
¡¡¡¡java.util.Da
Ïà¹ØÎĵµ£º
1.ÌáǰдºÃ±¸·Ý.bat£¬·ÅÔÚij¸öÎļþ¼ÐÀ½«Â·¾¶ÉèÖÃÔÚ.propertiesÀïµÄ
@echo off
set txt=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
echo %txt%
echo --------------------------------------------------
echo -------------ÕýÔÚÖ´ÐÐoracleÊý¾Ý¿â±¸·Ý--------------
echo ----- ......
JavaÖУ¬Jniµ÷ÓÃDLLÎļþÊÔÑé
ËùÓÐÎļþ¾ùÔÚE:\·¾¶Ï¡£
°²×°jdk1.6.0_07
°²×°ÁËVC++6.0
µÚÒ»²½£¬
HelloWorld.java
µÚ¶þ²½£¬
E:\>javac HelloWorld.java
µÃµ½
HelloWorld.class
µÚÈý²½£¬
E:\>javah HelloWorld
µÃµ½
HelloWorld.h
µÚËIJ½£¬
±àдһ¸öCÎļþ
HelloWorldImp.c
µÚÎå²½£¬
ʹÓÃcl±àÒ ......
1¡¢ http://java.sun.com/ ;;(Ó¢ÎÄ)
SunµÄJavaÍøÕ¾£¬ÊÇÒ»¸öÓ¦¸Ã¾³£È¥¿´µÄµØ·½¡£²»Óöà˵¡£
2¡¢ http://www-900.ibm.com/developerWorks/cn/ ;;
IBMµÄdeveloperWorksÍøÕ¾£¬Ó¢ÓïºÃµÄÖ±½ÓÈ¥Ó¢ÎÄÖ÷Õ¾µã¿´¡£ÕâÀï²»µ«ÊÇÒ»¸ö¼«ºÃµÄÃæÏò¶ÔÏóµÄ·ÖÎöÉè¼ÆÍøÕ¾£¬Ò²ÊÇWeb Services£¬Java£¬Linux¼«ºÃµÄÍøÕ¾¡£Ç¿ÁÒÍÆ¼ö£¡£¡£¡
3¡¢ h ......