Пример #1
0
 /**
  * Metodo para abrir um arquivo.
  *
  * @param file
  * @throws br.com.topsys.exception.TSSystemException
  */
 public void openFile(String file) {
   try {
     reader = new BufferedReader(new FileReader(file));
   } catch (FileNotFoundException e) {
     TSLogUtil.getInstance().severe(e.getMessage());
     throw new TSSystemException(e);
   }
 }
Пример #2
0
  /**
   * Esse metodo ser� usado para gravar o arquivo passando como parametro o caminho fisico do
   * arquivo.
   *
   * @param arquivo
   * @throws br.com.topsys.exception.TSSystemException
   */
  public void save(String arquivo) {
    try {
      out = new PrintWriter(new BufferedWriter(new FileWriter(arquivo)));
      out.println(string.toString());

    } catch (IOException e) {
      TSLogUtil.getInstance().severe(e.getMessage());
      throw new TSSystemException(e);
    } finally {
      try {
        out.close();
      } catch (Exception e) {
      }
    }
  }
Пример #3
0
 public String formatarSQL() {
   StringBuffer string = new StringBuffer();
   String linha = null;
   try {
     while (reader.ready()) {
       linha = reader.readLine().trim();
       if (!TSUtil.isEmpty(linha)) {
         string.append(linha);
         string.append(" ");
       }
     }
   } catch (IOException e) {
     TSLogUtil.getInstance().severe(e.getMessage());
     throw new TSSystemException(e);
   }
   return string.toString();
 }
Пример #4
0
  /**
   * Metodo para ler o arquivo.
   *
   * @return
   * @throws br.com.topsys.exception.TSSystemException
   */
  public String readAllFile() {
    StringBuffer string = new StringBuffer();

    try {
      while (reader.ready()) {
        string.append(reader.readLine());
        string.append("\n");
      }
    } catch (IOException e) {
      TSLogUtil.getInstance().severe(e.getMessage());
      throw new TSSystemException(e);
    } finally {
      try {
        reader.close();
      } catch (Exception e) {
      }
    }
    return string.toString();
  }
Пример #5
0
  public String desFormatarSQL() {

    String linha = null;
    try {
      if (reader.ready()) {
        linha = reader.readLine().trim();
      }
      if (!TSUtil.isEmpty(linha)) {
        linha = linha.replaceAll("SELECT", "\nSELECT");
        linha = linha.replaceAll("UNION", "\nUNION");
        linha = linha.replaceAll("AND", "\nAND");
        linha = linha.replaceAll("WHERE", "\nWHERE");
        linha = linha.replaceAll("FROM", "\nFROM");
      }
    } catch (IOException e) {
      TSLogUtil.getInstance().severe(e.getMessage());
      throw new TSSystemException(e);
    }
    return linha;
  }