我将mongodb数据导出到* .csv文件中。但问题是我想在远程系统中拥有转储或* .csv文件。在尝试的时候,我不打算!!
Runtime runtime = Runtime.getRuntime();
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
Date date = new Date();
String xyz=dateFormat.format(date);
String query="mongoexport --host "+" "+ipAdders+" "+"-d SMPP -c UserMessages
--csv --fieldFile /root/Documents/UserMessagesFileds.txt -o"+" "+xyz+".csv";
try {
Process process=runtime.exec(query);
System.out.println(query);
System.out.println(xyz);
if( null!=process && process.waitFor() == 0 &&process.exitValue()== 0 ){
System.out.println("Command executed sucessfully");
}
else{
}
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
此代码在我的系统中存储* .csv文件,但我希望它在远程系统中,如(192.168.0.139)。