[Java]20·Ç³£ÓÐÓõÄJava³ÌÐòƬ¶Î
1. ×Ö·û´®ÓÐÕûÐ͵ÄÏ໥ת»»
1
2 String a = String.valueOf(2); //integer to numeric string
3 int i = Integer.parseInt(a); //numeric string to an int
2. ÏòÎļþĩβÌí¼ÓÄÚÈÝ
01
02 BufferedWriter out = null;
03 try {
04 out = new BufferedWriter(new FileWriter(”filename”, true));
05 out.write(”aString”);
06 } catch (IOException e) {
07 // error processing code
08 } finally {
09 if (out != null) {
10 out.close();
11 }
12 }
3. µÃµ½µ±Ç°·½·¨µÄÃû×Ö
1 String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
4. ת×Ö·û´®µ½ÈÕÆÚ
1
2 java.util.Date = java.text.DateFormat.getDateInstance().parse(date String);
»òÕßÊÇ£º
1
2 SimpleDateFormat format = new SimpleDateFormat( "dd.MM.yyyy" );
3 Date date = format.parse( myString );
5. ʹÓÃJDBCÁ´½ÓOracle
01 public class OracleJdbcTest
02 {
03 String driverClass = "oracle.jdbc.driver.OracleDriver";
04
05 Connection con;
06
07 public void init(FileInputStream fs) throws ClassNotFoundException, SQLException, FileNotFoundException, IOException
08 {
09 Properties props = new Properties();
10 props.load(fs);
11 String url = props.getProperty("db.url");&nbs
Ïà¹ØÎĵµ£º
ÔõôѧϰJava£¬ÕâÊǺܶàÐÂÊÖ¾³£»áÎÊÎÒµÄÎÊÌ⣬ÏÖÔÚÎÒ¼òµ¥ÃèÊöÏÂÒ»¸öJava³õѧÕßµ½¾ÍҵҪѧµ½µÄһЩ¶«Î÷£º
Ê×ÏÈÒªÃ÷°×JavaÌåϵÉè¼Æµ½µÃÈý¸ö·½Ã棺J2SE,J2EE,J2ME£¨KJAVA£©¡£J2SE£¬Java 2 Platform Standard
Edition£¬ÎÒÃǾ³£Ëµµ½µÄJDK£¬¾ÍÖ÷ÒªÖ¸µÄÕâ¸ö£¬ËüÊÇÈýÕߵĻù ......
package com.hefeng.test;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.uti ......
È¡:
Cookie[] cookies = request.getCookies();
if(cookies!=null){
for(Cookie cookie : cookies){
if(cookie.getName().equals("mid")){
String mid = cookie.getValue();
}
}
}
´æ:
String mid ......
package com.hongsoft.test;
import java.io.*;
//¶¨ÖƵÄÀà×°ÈëÆ÷
public class TestCompile extends ClassLoader
{
String _compiler;
String _classpath;
public static void main(String[] args)
{
new TestCompile();
}
public TestCompile()
{
super(ClassLoader.getSystemClassLoader());
//ĬÈϱàÒëÆ ......