java實現mysql的匯入和匯出

2021-09-01 01:44:38 字數 1013 閱讀 9199

public class sqlbackup 

public static void backup()

outstr = sb.tostring();

// 要用來做匯入用的sql目標檔案:

fileoutputstream fout = new fileoutputstream(

"e:/test.sql");

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("/* output ok! */");

} catch (exception e)

} public static void load()

outstr = sb.tostring();

outputstreamwriter writer = new outputstreamwriter(out, "utf8");

writer.write(outstr);

// 注:這裡如果用緩衝方式寫入檔案的話,會導致中文亂碼,用flush()方法則可以避免

writer.flush();

// 別忘記關閉輸入輸出流

out.close();

br.close();

writer.close();

system.out.println("/* load ok! */");

} catch (exception e)

} }

java實現excel的匯入匯出

最進接觸到excel匯入匯出。可以使用poi.jar實現。下面是乙個hello word import org.apache.poi.hssf.usermodel.hssfcell import org.apache.poi.hssf.usermodel.hssfrow import org.apa...

java實現excel的匯入匯出

最進接觸到excel匯入匯出。可以使用poi.jar實現。下面是乙個hello word import org.apache.poi.hssf.usermodel.hssfcell import org.apache.poi.hssf.usermodel.hssfrow import org.apa...

JAVA實現Excel匯入匯出

建立工程匯入jar包 jxl建立excel檔案 author c public class jxlexpexcel 建立excel檔案 file file new file jxl test.xls try 追加資料 for int i 1 i 10 i 寫入資料 workbook.write wo...