MongoDB中的架构:
{
“名称”:“ Kamala”,
“流量”:[
{
"Date" : "2018-08-03",
"New" : "set",
"Form" : {
"y" : "1",
"d" : "3",
"p" : "3"
}
}
]
}
我的Java代码: 公共静态void main(String [] args){
String db = "Database";
String col = "col";
String Host="localhost";
String Port="27017";
String fileName = "D:/File/sample.xls";
String Query = "C:\\Program Files\\MongoDB\\Server\\3.4\\bin\\mongoexport.exe --host " + Host + " --port " + Port + " --db " + db + " --collection " + col + " --type=xls--fields Name,Flows, --out " + fileName + "";
try {
System.out.println(Query);
StringTokenizer st = new StringTokenizer(Query);
String[] Queryarray = new String[st.countTokens()];
for (int i = 0; st.hasMoreTokens(); i++)
Queryarray[i] = st.nextToken();
ProcessBuilder processBuilder = new ProcessBuilder(Queryarray);
processBuilder.redirectErrorStream(true);
Process process = processBuilder.start();
BufferedReader processOutput = new BufferedReader(new InputStreamReader(process.getInputStream()));
String data = "";
while ((data = processOutput.readLine()) != null) {
System.out.println(data);
}
} catch (Exception e) {
e.printStackTrace();
}
}
我正在尝试检索Flows数组中的日期,新值,表单值