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

java´úÂëÖ´ÐÐmysqlµÄÊý¾Ý±¸·ÝºÍÅúÁ¿Êý¾Ý²åÈ룡

mysqlÊý¾Ý¿â±¾ÉíÓÐÊý¾Ý±¸·ÝºÍÅúÁ¿Êý¾Ý²åÈëµÄÃüÁjava´úÂë¿ÉÖ´ÐÐÕâЩÃüÁî¡£
°²×°mysqlºó£¬ÐèÒªÉèÖû·¾³±äÁ¿£ºÎҵĵçÄÔÓÒ»÷--ÊôÐÔ--¸ß¼¶--»·¾³±äÁ¿£¬Ôö¼ÓMYSQL_HOME=“mysql°²×°Â·¾¶”£¬È»ºópath=%MYSQL_HOME%\bin
´úÂëÈçÏ£º
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
public class OperateDb {
private String user;
private String password;
private String filePath;
private String dbip;
//±¸·ÝÊý¾Ý
public void backup() {
try {
Runtime rt = Runtime.getRuntime();
//ÐγÉcmdÃüÁî
String cmd = "mysqldump -u"+user+" -p"+password+" -h"+dbip+" --set-charset=utf8 -t --no-create-info recommend movieinfo";
// µ÷Óà mysql µÄ cmd,ÉèÖõ¼³ö±àÂëΪutf8¡£ÕâÀï±ØÐëÊÇutf8
Process child = rt.exec(cmd);
// °Ñ½ø³ÌÖ´ÐÐÖеĿØÖÆ̨Êä³öÐÅϢдÈë.sqlÎļþ£¬¼´Éú³ÉÁ˱¸·ÝÎļþ¡£×¢£ºÈç¹û²»¶Ô¿ØÖÆ̨ÐÅÏ¢½øÐжÁ³ö£¬Ôò»áµ¼Ö½ø³Ì¶ÂÈûÎÞ·¨ÔËÐÐ
// ¿ØÖÆ̨µÄÊä³öÐÅÏ¢×÷ΪÊäÈëÁ÷
InputStream in = child.getInputStream();
// ÉèÖÃÊä³öÁ÷±àÂëΪutf8¡£ÕâÀï±ØÐëÊÇutf8£¬·ñÔò´ÓÁ÷ÖжÁÈëµÄÊÇÂÒÂë
InputStreamReader xx = new InputStreamReader(in, "utf8");
String inStr;
StringBuffer sb = new StringBuffer("");
String outStr;
// ×éºÏ¿ØÖÆ̨Êä³öÐÅÏ¢×Ö·û´®
BufferedReader br = new BufferedReader(xx);
while ((inStr = br.readLine()) != null) {
sb.append(inStr + "\r\n");
}
outStr = sb.toString();
// ÒªÓÃÀ´×öµ¼ÈëÓõÄsqlÄ¿±êÎļþ£º
FileOutputStream fout = new FileOutputStream(filePath);
OutputStreamWriter writer = new OutputStreamWriter(fout, "utf8");
writer.write(outStr);

//ÕâÀïÈç¹ûÓûº³å·½Ê½Ð´ÈëÎļþµÄ»°£¬»áµ¼ÖÂÖÐÎÄÂÒÂ룬ÓÃflush()·½·¨Ôò¿ÉÒÔ±ÜÃâ
writer.flush();
//¹Ø±ÕÊäÈëÊä³öÁ÷
in.close();
xx.close();
br.close();
writer.close();
fout.close();
System.out.println("Êý¾Ý³É¹¦±¸·Ýµ½"+filePath);
} catch (Exception e) {
e.printS


Ïà¹ØÎĵµ£º

Java NIO APIÏê½â

 
Java NIO APIÏê½â
ÔÚJDK
1.4ÒÔÇ°£¬JavaµÄIO²Ù×÷¼¯ÖÐÔÚjava.ioÕâ¸ö°üÖУ¬ÊÇ»ùÓÚÁ÷µÄ×èÈû£¨blocking£©API¡£¶ÔÓÚ´ó¶àÊýÓ¦ÓÃÀ´Ëµ£¬ÕâÑùµÄAPIʹÓúܷ½
±ã£¬È»¶ø£¬Ò»Ð©¶ÔÐÔÄÜÒªÇó½Ï¸ßµÄÓ¦Óã¬ÓÈÆäÊÇ·þÎñ¶ËÓ¦Óã¬ÍùÍùÐèÒªÒ»¸ö¸üΪÓÐЧµÄ·½Ê½À´´¦ÀíIO¡£´ÓJDK 1.4Æð£¬NIO
API×÷Ϊһ¸ö»ùÓÚ»º³åÇø£¬²¢ÄÜÌṩ·Ç×èÈû(non-blo ......

Java רҵÈËÊ¿±Ø±¸Êé¼®ºÍÍøÕ¾Áбí

¡¡¡¡¶ÔÓÚ Java ÓïÑÔ¿ª·¢ÈËÔ±À´Ëµ£¬ÐÅÏ¢¹ýÁ¿ÊÇÒ»¸öÕæÕýµÄÎÊÌ⡣ÿ¸öÐÂÈëÐеijÌÐòÔ±¶¼ÒªÃæÁÙÒ»¸öÁîÈËηËõµÄÌôÕ½£ºÒª½øÈëµÄÐÐÒµÊÇÒ»¸ö¾ßÓк£Á¿ÖªÊ¶µÄÐÐÒµ¡£ÒªÁ˽âµÄ¶«Î÷¼òֱ̫¶àÁË¡£¶ÔÓÚÓо­ÑéµÄÀÏÊÖÀ´Ëµ£¬Çé¿öÖ»ÓÐЩ΢ºÃת¡£ÖªÊ¶Á¿×ÜÔÚÔö´ó£¬½ö½ö¸úÉϽø¶È¾ÍÊÇÒ»¸öÌôÕ½¡£Èç¹ûÓÐÒ»·ÝרҵÈËÊ¿±Ø±¸µÄÊé¼®ºÍÍøÕ¾Áбí¸ÃÓжàºÃ!±¾Îľ ......

Java½âÎöXMLÎļþµÄËÄÖÖ·½·¨

 1£©DOM£¨JAXP Crimson½âÎöÆ÷£©
    DOMÊÇÓÃÓëƽ̨ºÍÓïÑÔÎ޹صķ½Ê½±íʾXMLÎĵµµÄ¹Ù·½W3C±ê×¼¡£DOMÊÇÒÔ²ã´Î½á¹¹×éÖ¯µÄ½Úµã»òÐÅϢƬ¶ÏµÄ¼¯ºÏ¡£Õâ¸ö²ã´Î½á¹¹ÔÊÐí¿ª·¢ÈËÔ±ÔÚÊ÷ÖÐÑ°ÕÒÌض¨ÐÅÏ¢¡£·ÖÎö¸Ã½á¹¹Í¨³£ÐèÒª¼ÓÔØÕû¸öÎĵµºÍ¹¹Ôì²ã´Î½á¹¹£¬È»ºó²ÅÄÜ×öÈκι¤×÷¡£ÓÉÓÚËüÊÇ»ùÓÚÐÅÏ¢²ã´ÎµÄ£¬Òò¶ ......

Java·ºÐÍÓ¦¸Ã×¢ÒâµÄϸ½Ú

1¡¢²»¿ÉÒÔÓÃÒ»¸ö±¾µØÀàÐÍ£¨Èçint   float£©À´Ìæ»»·ºÐÍ.±ÈÈçList<Integer>²»ÄÜÓÃList<int>ÐÍʽ
2¡¢ÔËÐÐʱÀàÐͼì²é£¬²»Í¬ÀàÐ͵ķºÐÍÀàÊǵȼ۵ģ¨Pair<String>ÓëPair<Employee>ÊÇÊôÓÚͬһ¸ö
ÀàÐÍ Pair£©£¬ÕâÒ»µãÒªÌرð×¢Òâ:¼´Èç¹ûa instanceof
Pair<String>==trueµÄ»°£¬²¢²»´ú±ía. ......

JavaÈÕÆÚÀà³£Ó÷½·¨

1.½«ÈÕÆÚ´æÈëDate¶ÔÏó
SimpleDateFormatÊÇÒ»¸öÈÕÆÚ¸ñʽ»¯Àà¡£yyyy£¬MM£¬dd£¬HH£¬mm,ss,SSS·Ö±ð±íʾÄ꣬Ô£¬ÈÕ£¬Ê±£¬·Ö£¬Ã룬ºÁÃë¡£¿ÉÒÔ½«ËûÃÇËæÒâ×éºÏ£¬¹¹½¨×Ô¼ºµÄÈÕÆÚ¸ñʽ¡£
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
È»ºóÖ»ÐèÒª½«·ûºÏÈÕÆÚ¸ñʽµÄÈÕÆÚ×Ö·û´®´æÈëDate¶ÔÏóÖС£
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ