问题描述
用的是mysql数据库备份没有问题就是恢复一部分的时候报异常!!!!
publicstaticvoidrestore(){Stringcommand=mysqlBinPath+"mysql-u"+username+"-p"+password+""+dbname;try{Processprocess=Runtime.getRuntime().exec(command);OutputStreamout=process.getOutputStream();Stringline=null;StringoutStr=null;StringBuffersb=newStringBuffer("");InputStreaminput=newFileInputStream(destPath);BufferedReaderbr=newBufferedReader(newInputStreamReader(input,"utf8"));OutputStreamWriterwriter=newOutputStreamWriter(out,"utf8");while((line=br.readLine())!=null){writer.write(line);writer.write("rn");}//writer.write(outStr);writer.flush();out.close();br.close();writer.close();System.out.println("fafa");}catch(UnsupportedEncodingExceptione){e.printStackTrace();}catch(IOExceptione){e.printStackTrace();}}在线等高手呀。。。!!!
解决方案
解决方案二:
自己顶一下!
解决方案三:
字符编码的问题Stringcommand=mysqlBinPath+"mysql-u"+username+"-p"+password+""+dbname;try{Processprocess=Runtime.getRuntime().exec(command);修改为:Stringcommand=mysqlBinPath+"mysql--default-character-set=utf8-u"+username+"-p"+password+""+dbname;try{Processprocess=Runtime.getRuntime().exec(command);
解决方案四:
请问楼主解决了吗?我也是这样一个问题