public void write(
      String citationFilename,
      List<String> variableNameSet,
      String subsetUNF,
      String subsettingCriteria) {
    OutputStream outs = null;
    if (subsetUNF == null) {
      subsetUNF = "";
    }
    if (subsettingCriteria == null) {
      subsettingCriteria = "";
    }
    try {
      File cf = new File(citationFilename);
      outs = new BufferedOutputStream(new FileOutputStream(cf));
      PrintWriter pw = new PrintWriter(new OutputStreamWriter(outs, "utf8"), true);
      pw.println(title);
      pw.println(offlineCitation);

      if (generateSubsetCriteriaLine().equals("")) {
        pw.println("\n\n");
      } else {
        pw.println("\n");
        pw.println(generateSubsetCriteriaLine() + "\n");
      }
      pw.println(subsetTitle);
      pw.print(offlineCitation + " ");
      pw.print(DvnDSButil.joinNelementsPerLine(variableNameSet, 5));
      pw.println(" [VarGrp/@var(DDI)];");
      pw.println(subsetUNF);
      outs.close();
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }
  public void write(File cf) {

    OutputStream outs = null;
    try {
      outs = new BufferedOutputStream(new FileOutputStream(cf));
      PrintWriter pw = new PrintWriter(new OutputStreamWriter(outs, "utf8"), true);
      pw.println(title);
      pw.println(offlineCitation);

      if (generateSubsetCriteriaLine().equals("")) {
        pw.println("\n\n");
      } else {
        pw.println("\n");
        pw.println(generateSubsetCriteriaLine() + "\n");
      }
      pw.println(subsetTitle);
      pw.print(offlineCitation + " ");
      pw.print(variableList);
      pw.println(" [VarGrp/@var(DDI)];");
      pw.println(subsetUNF);
      outs.close();
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }
Пример #3
0
 static void searchFiles() {
   try {
     for (int i = 0; i < options.filenames.length; i++) {
       Scanner input = new Scanner(new File(options.filenames[i]));
       scanfile(input, options.filenames[i], options.pattern);
       input.close();
     }
   } catch (IOException e) {
     messages.warn(e.getMessage());
     messages.exit_status = messages.EXIT_NOMATCH;
   }
 }
  public void writeWholeFileCase(File cf) {
    OutputStream outs = null;
    try {
      outs = new BufferedOutputStream(new FileOutputStream(cf));
      PrintWriter pw = new PrintWriter(new OutputStreamWriter(outs, "utf8"), true);
      pw.println(title);
      pw.println(offlineCitation);

      outs.close();
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }
  public static void main(String[] args) {
    File db = new File(DB_FILE);
    FileOutputStream fs;

    try {
      fs = new FileOutputStream(db, true);

      DataOutputStream dos = new DataOutputStream(fs);

      IEmployee employee1 =
          new Employee("Carol", "Lindsey", 43, "ofice-assistant", new BigDecimal(1760));
      IEmployee employee2 = new Employee("Gorden", "Brown", 56, "cleaner", new BigDecimal(1230));
      IEmployee employee3 = new Employee("Brian", "Lindsey", 47, "CSO", new BigDecimal(5760));

      try {
        dos.writeChars(employee1.toString());
        dos.writeChars("\n");

        dos.writeChars(employee2.toString());
        dos.writeChars("\n");

        dos.writeChars(employee3.toString());
        dos.writeChars("\n");

        dos.close();
      } catch (IOException e) {
        out.printf("Cannot write to file (%s). %s", DB_FILE, e.toString());
      }

      fs.close();
    } catch (FileNotFoundException e) {
      out.printf("File not found (%s). %s", DB_FILE, e.toString());
      //         e.printStackTrace();  //To change body of catch statement use File | Settings |
      // File Templates.
    } catch (IOException e) {
      out.printf("Couldn't close file (%s). %s", DB_FILE, e.toString());
      //         e.printStackTrace();  //To change body of catch statement use File | Settings |
      // File Templates.
    }
  }