/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package CSP_ANALYSE; import LOGIC.Contract; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.InputStreamReader; import java.io.PrintWriter; import javax.swing.JOptionPane; /** * * @author sarah */ public class ReadFileCSP { private Contract contract; private double temp; public ReadFileCSP(Contract c) { contract = c; } public double getTemp() { return temp; } public void setTemp(double t) { this.temp = t; } public void saidaFDR() { setTemp(System.currentTimeMillis()); FileWriter saida = null; File pegarpath = new File("path.txt"); if (!pegarpath.exists()) { System.exit(-1); } try { //parte que pega o caminho fdr String path; BufferedReader pegarResultado = new BufferedReader(new FileReader(pegarpath)); path = pegarResultado.readLine(); // saida = new FileWriter(new File("fdrLog/"+contract.getName()+"_saida_"+getTemp()+".log")); PrintWriter d = new PrintWriter(saida); d.flush(); String line; Process p = Runtime.getRuntime().exec(path + "./fdr2 batch -trace cspFiles/"+contract.getName()+".csp"); BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); //para pegar a mensagem que foi tipada corretamente while ((line = in.readLine()) != null) { d.write(line + "\n"); } in.close(); saida.close(); d.close(); p.waitFor(); java.lang.System.out.println("Done."); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, "The path of FDR undefined"); } } }