Java °ÑÎı¾ÖеÄÊý¾Ý²åÈëµ½MySqlÊý¾Ý¿â
Ò»¹²ÓÐÈý¸öÀࣺWriteFile ; ReadFile ; InsertDB ;
//WriteFile.java
//ÓÃÓÚ½«ÐÅϢдÈëÎı¾Îļþ
package org.mb.insertfromfile;
import java.io.*;
public class WriteFile{
private int count = 0 ;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public void write() throws Exception{
File f = new File("f:\\stu1.dat");
f.createNewFile();
FileOutputStream fos = new FileOutputStream(f);
DataOutputStream dos = new DataOutputStream(fos);
this.count++;
dos.writeUTF("ºé¼ªÍ¯");
dos.writeInt(80);
dos.writeInt(75);
dos.writeInt(65);
dos.writeInt(50);
this.count++;
dos.writeUTF("Ðì¹âºÀ");
dos.writeInt(90);
dos.writeInt(100);
dos.writeInt(100);
dos.writeInt(100);
this.count++;
dos.writeUTF("ÁÖ˳ϲ");
dos.writeInt(60);
dos.writeInt(70);
dos.writeInt(55);
dos.writeInt(75);
this.count++;
dos.writeUTF("Àî֮÷");
dos.writeInt(60);
dos.writeInt(80);
dos.writeInt(75);
dos.writeInt(80);
this.count++;
dos.writeUTF("ºé˳Îõ");
dos.writeInt(80);
dos.writeInt(70);
dos.writeInt(90);
dos.writeInt(85);
this.count++;
dos.writeUTF("ÆÓ˳¼ª");
dos.writeInt(100);
dos.writeInt(80);
dos.writeInt(90);
dos.writeInt(85);
dos.flush();
dos.close();
}
}
//ReadFile.java
//ÓÃÓÚ·µ»ØÎı¾ÖеÄÐÅÏ¢
package org.mb.insertfromfile;
import java.io.*;
public class ReadFile {
public String[] read()throws Exception{
WriteFile wr = new WriteFile();
wr.write();
String str[] = new String[wr.getCount()];
File f = new File("F:\\stu.dat");
FileInputStream fis = new FileInputStream(f);
DataInputStream dis = new DataInputStream(fis);
for (int i=0 ; i<str.length ; i++){
str[i] = "'"+dis.readUTF()+"'"+","+dis.readInt()+","+dis.readInt()+","+dis.readInt()+","+dis.readInt();
System.out.p
Ïà¹ØÎĵµ£º
ÀàµÄ³õʼ»¯ºÍ¶ÔÏó³õʼ»¯ÊÇ JVM ¹ÜÀíµÄÀàÐÍÉúÃüÖÜÆÚÖзdz£ÖØÒªµÄÁ½¸ö»·½Ú£¬Google ÁËÒ»±éÍøÂ磬ÓйØÀà×°ÔØ»úÖƵÄÎÄÕµ¹ÊDz»ÉÙ£¬È»¶øÀà³õʼ»¯ºÍ¶ÔÏó³õʼ»¯µÄÎÄÕ²¢²»¶à£¬ÌرðÊÇ´Ó×Ö½ÚÂëºÍ JVM ²ã´ÎÀ´·ÖÎöµÄÎÄÕ¸üÊÇÏÊÓÐËù¼û¡£
±¾ÎÄÖ÷Òª¶ÔÀàºÍ¶ÔÏó³õʼ»¯È«¹ý³Ì½øÐзÖÎö£¬Í¨¹ýÒ»¸öʵ¼ÊÎÊÌâÒýÈ룬½«Ô´´úÂëת»»³É JVM ×Ö½ÚÂëºó£¬ ......
ÕâЩ¶¼ÊÇÄúÊé¼ÜÉϱر¸µÄÊéºÍÓ¦¸Ã¾³£Ê¹ÓÃµÄ Web Á´½Ó¡£Ê±¼äÊÇÒ»ÏîÖØÒªµÄ×ÊÔ´£¬±¾ÎÄ°ïÄú»Ø±ÜÄÇЩ·ÖÐĵÄÊÂÇ飬°Ñʱ¼äרעÓÚ×îÓÐÒæÓÚÄú×÷ΪJava ÓïÑÔ³ÌÐòÔ±Ö°ÒµÉúÑĵÄÐÅÏ¢Ô´¡£¾¡¹ÜÓжàÉÙ³ÌÐòÔ±¾ÍÓжàÉÙËûÃÇ×îϲ»¶µÄ²Î¿¼×ÊÁÏ£¬µ«±¾ÎÄÊÕ¼¯µÄÕâЩ¶¼ÊÇÓÅÖÐÑ¡ÓÅ£¬À´Ô´ÓÚÎÒÊé¼ÜÉϵÄ˽¼ÒÕä²ØºÍÐí¶à Java ר¼ÒµÄÍƼö¡£
ÎÒ¿¼ÂÇÁËÁ½ÖÖ×é ......
javaÁ¬½Ó¸÷ÖÖÊý¾Ý¿â·½Ê½ËÙ²é±í1£®Oracle8/8i/9iÊý¾Ý¿â£¨thinģʽ£©Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orclΪÊý¾Ý¿âµÄSID
String user="test";
String password="test";
Connection conn= DriverManager.getConnection(url,u ......
File.separatorChar ·µ»ØÒ»¸ö×Ö·û£¬±íʾµ±Ç°ÏµÍ³Ä¬ÈϵÄÎļþÃû·Ö¸ô·û£¬ÔÚWindowsÖÐΪ"\",unixÖÐΪ"/"¡£
File.separator ÓëÇ°ÕßÏàͬ£¬µ«½«·Ö¸ô·û×÷Ϊ×Ö·û´®ÀàÐÍ·µ»Ø¡£
pathSeparatorChar ·µ»ØÒ»¸ö×Ö·û£¬±íʾµ±Ç°ÏµÍ³Ä¬ÈϵÄ·¾¶Ãû·Ö¸ô·û£¬ÔÚWindowsÖÐΪ";",unixÖÐΪ":"¡£
File.pathSeparator ÓëÇ°ÕßÏàͬ£¬µ«½«·Ö¸ô·û×÷Ϊ×Ö· ......
¿ÉÄܺܶàjavaµÄ³õѧÕ߶ÔStringµÄ´æ´¢ºÍ¸³ÖµÓÐÃÔ»ó£¬ÒÔÏÂÊÇÒ»¸öºÜ¼òµ¥µÄ²âÊÔÓÃÀý£¬ÄãÖ»ÐèÒª»¨¼¸·ÖÖÓʱ¼ä±ã¿ÉÀí½â¡£
1.ÔÚ¿´Àý×Ó֮ǰ£¬È·±£ÄãÀí½âÒÔϼ¸¸öÊõÓ
Õ» £ºÓÉJVM·ÖÅäÇøÓò£¬ÓÃÓÚ±£´æÏß³ÌÖ´ÐеĶ¯×÷ºÍÊý¾ÝÒýÓá£Õ»ÊÇÒ»¸öÔËÐеĵ¥Î»£¬JavaÖÐÒ»¸öÏ߳̾ͻáÏàÓ¦ÓÐÒ»¸öÏß³ÌÕ»ÓëÖ®¶ÔÓ¦¡£
¶Ñ £ºÓÉJVM·ÖÅäµÄ£¬ÓÃÓÚ´æ´¢¶Ô ......