示例#1
0
  // writes the passed string to the passed file
  private void setContents(File file, String content) {
    try {
      BufferedWriter output = new BufferedWriter(new FileWriter(file));

      output.write(content);
      output.close();
    } catch (Exception e) {
      System.out.println("Encryption/Decryption File Error: " + e);
    }
  }
示例#2
0
    public void run() {
      try {
        BufferedReader br =
            new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
        if (outputFile != null) {
          bw =
              new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), charset));
        }
        String line;
        while ((line = br.readLine()) != null) {
          filePosition += line.length() + 2;
          line = line.trim();
          if (!line.startsWith("#")) {
            String[] sides = split(line);
            if ((sides != null) && !sides[0].equals("key")) {

              if (searchPHI) {
                // Search the decrypted PHI for the searchText
                sides[0] = decrypt(sides[0]);
                if (sides[0].indexOf(searchText) != -1) {
                  output(sides[0] + " = " + sides[1] + "\n");
                }
              } else {
                // Search the trial ID for the searchText
                if (sides[1].indexOf(searchText) != -1) {
                  sides[0] = decrypt(sides[0]);
                  output(sides[0] + " = " + sides[1] + "\n");
                }
              }
            }
          }
        }
        br.close();
        if (bw != null) {
          bw.flush();
          bw.close();
        }
      } catch (Exception e) {
        append("\n\n" + e.getClass().getName() + ": " + e.getMessage() + "\n");
      }
      append("\nDone.\n");
      setMessage("Ready...");
    }
示例#3
0
    private void output(String string) throws Exception {
      if (bw != null) bw.write(string);
      else append(string);

      // Set the fraction done.
      long pct = (filePosition * 100) / fileLength;
      if (pct != percentDone) {
        percentDone = pct;
        setMessage("Working... (" + pct + "%)");
      }
    }