import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import com.alibaba.fastjson.JSON;
public class Demo {
public static void main(String[] args){
String json = "null";
try {
json = readJsonData("C:\\Users\\0\\Desktop\\数据接入\\机组日指标.txt");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
List<HashMap> list =JSON.parseArray(json, HashMap.class);
for(int i=0;i<list.size();i++){
System.out.println("insert into jizurizhibiao VALUES "+"("+"'"+list.get(i).get("code")+"'"+","+"'"+list.get(i).get("unit")+"'"+","+"'"+list.get(i).get("date")+"'"+","+list.get(i).get("value")+","+"'"+list.get(i).get("name")+"'"+","+"'"+list.get(i).get("id")+"'"+")"+";");;
}
}
public static String readJsonData(String pactFile) throws IOException {
// 读取文件数据
//System.out.println("读取文件数据util");
StringBuffer strbuffer = new StringBuffer();
File myFile = new File(pactFile);//"D:"+File.separatorChar+"DStores.json"
if (!myFile.exists()) {
System.err.println("Can't Find " + pactFile);
}
try {
FileInputStream fis = new FileInputStream(pactFile);
InputStreamReader inputStreamReader = new InputStreamReader(fis, "UTF-8");
BufferedReader in = new BufferedReader(inputStreamReader);
String str;
while ((str = in.readLine()) != null) {
strbuffer.append(str); //new String(str,"UTF-8")
}
in.close();
} catch (IOException e) {
e.getStackTrace();
}
//System.out.println("读取文件结束util");
return strbuffer.toString();
}
}