@Override
  synchronized void incrementNextClaimID() {
    // increment in memory
    this.nextClaimID++;

    BufferedWriter outStream = null;

    try {
      // open the file and write the new value
      File nextClaimIdFile = new File(nextClaimIdFilePath);
      nextClaimIdFile.createNewFile();
      outStream = new BufferedWriter(new FileWriter(nextClaimIdFile));

      outStream.write(String.valueOf(this.nextClaimID));
    }

    // if any problem, log it
    catch (Exception e) {
      GriefPrevention.AddLogEntry("Unexpected exception saving next claim ID: " + e.getMessage());
    }

    // close the file
    try {
      if (outStream != null) outStream.close();
    } catch (IOException exception) {
    }
  }
  // grants a group (players with a specific permission) bonus claim blocks as
  // long as they're still members of the group
  @Override
  synchronized void saveGroupBonusBlocks(String groupName, int currentValue) {
    // write changes to file to ensure they don't get lost
    BufferedWriter outStream = null;
    try {
      // open the group's file
      File groupDataFile = new File(playerDataFolderPath + File.separator + "$" + groupName);
      groupDataFile.createNewFile();
      outStream = new BufferedWriter(new FileWriter(groupDataFile));

      // first line is number of bonus blocks
      outStream.write(String.valueOf(currentValue));
      outStream.newLine();
    }

    // if any problem, log it
    catch (Exception e) {
      GriefPrevention.AddLogEntry(
          "Unexpected exception saving data for group \"" + groupName + "\": " + e.getMessage());
    }

    try {
      // close the file
      if (outStream != null) {
        outStream.close();
      }
    } catch (IOException exception) {
    }
  }
Exemple #3
0
  /**
   * given a list of sequences, creates a db for use with blat
   *
   * @param seqList is the list of sequences to create the database with
   * @return the full path of the location of the database
   */
  private String dumpToFile(Map<String, String> seqList) {

    File tmpdir;
    BufferedWriter out;
    File seqFile = null;

    /*
    open temp file
     */
    try {
      seqFile = new File(tmpDirFile, "reads.fa");
      out = new BufferedWriter(new FileWriter(seqFile.getPath()));

      /*
      write out the sequences to file
      */
      for (String key : seqList.keySet()) {
        assert (seqList.get(key) != null);
        out.write(">" + key + "\n");
        out.write(seqList.get(key) + "\n");
      }

      /*
      close temp file
       */
      out.close();

    } catch (Exception e) {
      log.error(e);
      return null;
    }

    return seqFile.getPath();
  }
Exemple #4
0
  /**
   * copies a file from DFS to local working directory
   *
   * @param dfsPath is the pathname to a file in DFS
   * @return the path of the new file in local scratch space
   * @throws IOException if it can't access the files
   */
  private String copyDBFile(String dfsPath) throws IOException {

    Configuration conf = new Configuration();
    FileSystem fs = FileSystem.get(conf);

    Path filenamePath = new Path(dfsPath);
    File localFile = new File(tmpDirFile, filenamePath.getName());

    if (!fs.exists(filenamePath)) {
      throw new IOException("file not found: " + dfsPath);
    }

    FSDataInputStream in = fs.open(filenamePath);
    BufferedReader d = new BufferedReader(new InputStreamReader(in));

    BufferedWriter out = new BufferedWriter(new FileWriter(localFile.getPath()));

    String line;
    line = d.readLine();

    while (line != null) {
      out.write(line + "\n");
      line = d.readLine();
    }
    in.close();
    out.close();

    return localFile.getPath();
  }
  public void ServerConnectionIncoming(String peer1, String address, String port) {
    String filename = "peer_" + peer1 + "/log_peer_" + peer1 + ".log";
    File file = new File(filename);
    if (!file.exists()) {
      CreateLog(peer1);
    }

    try {
      FileWriter fw = new FileWriter(filename, true); // the true will append the new data
      BufferedWriter bw = new BufferedWriter(fw);
      String str =
          getDate()
              + "***Server for peer: "
              + peer1
              + " is ready to listen at :"
              + address
              + " at port : "
              + port;
      bw.write(str); // appends the string to the file
      bw.newLine();
      bw.close();
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
  }
 public static void main(String[] args) throws IOException {
   FileReader fin = new FileReader(new File("input.txt"));
   BufferedReader input = new BufferedReader(fin);
   FileWriter fout = new FileWriter(new File("output.txt"));
   BufferedWriter out = new BufferedWriter(fout);
   StringTokenizer str = new StringTokenizer(input.readLine());
   int n = Integer.parseInt(str.nextToken());
   str = new StringTokenizer(input.readLine());
   ArrayList<Integer>[] data = new ArrayList[5000];
   for (int i = 0; i < 5000; i++) data[i] = new ArrayList<Integer>();
   for (int i = 0; i < 2 * n; i++) {
     int x = Integer.parseInt(str.nextToken());
     data[x - 1].add(i + 1);
   }
   boolean okay = true;
   for (int i = 0; i < 5000; i++) if (data[i].size() % 2 == 1) okay = false;
   if (okay) {
     for (int i = 0; i < 5000; i++) {
       for (int j = 0; j < data[i].size() / 2; j++) {
         out.write(data[i].get(2 * j) + " " + data[i].get(2 * j + 1) + "\n");
       }
     }
   } else {
     out.write("-1");
   }
   out.close();
 }
  public void PieceDownload(String peer1, String peer2, int index, int pieces) {
    String filename = "peer_" + peer1 + "/log_peer_" + peer1 + ".log";
    File file = new File(filename);
    if (!file.exists()) {
      CreateLog(peer1);
    }

    try {
      FileWriter fw = new FileWriter(filename, true); // the true will append the new data
      BufferedWriter bw = new BufferedWriter(fw);
      String str =
          getDate()
              + ": Peer "
              + peer1
              + " has downloaded the piece "
              + index
              + " from Peer "
              + peer2
              + ". Now the number of pieces is "
              + pieces
              + ".";
      bw.write(str); // appends the string to the file
      bw.newLine();
      bw.close();
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
  }
  public void Have(String peer1, String peer2, int index) {
    String filename = "peer_" + peer1 + "/log_peer_" + peer1 + ".log";
    File file = new File(filename);
    if (!file.exists()) {
      CreateLog(peer1);
    }

    try {
      FileWriter fw = new FileWriter(filename, true); // the true will append the new data
      BufferedWriter bw = new BufferedWriter(fw);
      String str =
          getDate()
              + ": Peer "
              + peer1
              + " received the 'HAVE' message from Peer "
              + peer2
              + " for the piece "
              + index
              + ".";
      bw.write(str); // appends the string to the file
      bw.newLine();
      bw.close();
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
  }
Exemple #9
0
 void pln(String s) {
   try {
     bw.write(s);
     bw.write(System.lineSeparator());
   } catch (Exception ex) {
   }
 }
  public static void decry() {
    try {
      BufferedReader bf = new BufferedReader(new FileReader("ciphertext.txt"));
      BufferedWriter wr = new BufferedWriter(new FileWriter("plaintext.txt"));
      char rkey[] = new char[26];
      for (char i = 'a'; i <= 'z'; i++) {
        if (key.charAt(i - 'a') > 'z' || key.charAt(i - 'a') < 'a') continue;
        rkey[key.charAt(i - 'a') - 'a'] = i;
      }
      System.out.println(rkey);
      StringBuffer strb;
      String str;
      while (((str = bf.readLine())) != null) {
        strb = new StringBuffer(str);
        // System.out.println(strb);
        // String ans;
        for (int i = 0; i < strb.length(); i++) {
          if (strb.charAt(i) >= 'a' && strb.charAt(i) <= 'z') {
            strb.setCharAt(i, rkey[strb.charAt(i) - 'a']);
          }
        }
        System.out.println(strb.toString());
        wr.write(strb.toString());
        wr.newLine();
      }
      // keyf.close();
      wr.close();
      bf.close();

    } catch (IOException e) {

    }
  }
Exemple #11
0
  /**
   * create the info string; assumes that no values are null
   *
   * @param infoFields a map of info fields
   * @throws IOException for writer
   */
  private void writeInfoString(Map<String, String> infoFields) throws IOException {
    if (infoFields.isEmpty()) {
      mWriter.write(VCFConstants.EMPTY_INFO_FIELD);
      return;
    }

    boolean isFirst = true;
    for (Map.Entry<String, String> entry : infoFields.entrySet()) {
      if (isFirst) isFirst = false;
      else mWriter.write(VCFConstants.INFO_FIELD_SEPARATOR);

      String key = entry.getKey();
      mWriter.write(key);

      if (!entry.getValue().equals("")) {
        VCFInfoHeaderLine metaData = mHeader.getInfoHeaderLine(key);
        if (metaData == null
            || metaData.getCountType() != VCFHeaderLineCount.INTEGER
            || metaData.getCount() != 0) {
          mWriter.write("=");
          mWriter.write(entry.getValue());
        }
      }
    }
  }
  public static void main(String[] args) throws Exception {

    /*  BufferedReader br=new BufferedReader(new FileReader("input.txt"));
        BufferedWriter out=new BufferedWriter(new FileWriter("output.txt"));
    */
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 2000);
    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out), 2000);
    String[] s = br.readLine().split(" ");
    int n = Integer.parseInt(s[0]);
    int q = Integer.parseInt(s[1]);
    int num[] = new int[n + 1];
    int[] m = new int[3 * n + 1]; // size = 2*n+1
    Arrays.fill(num, -1);
    s = br.readLine().split(" ");
    for (int i = 1; i <= n; i++) num[i] = Integer.parseInt(s[i - 1]);
    /// build tree
    maketree(1, 1, n, m, num);

    for (int qq = 1; qq <= q; qq++) {
      s = br.readLine().split(" ");
      int i = Integer.parseInt(s[0]);
      int j = Integer.parseInt(s[1]);
      int ans = query(1, 1, n, m, num, i, j);
      out.write("" + num[ans] + "\n");
      out.flush();
    }
  }
    private boolean safeEquals(final ClasspathItemWrapper a, final ClasspathItemWrapper b) {
      try {
        final StringWriter as = new StringWriter();
        final StringWriter bs = new StringWriter();

        final BufferedWriter bas = new BufferedWriter(as);
        final BufferedWriter bbs = new BufferedWriter(bs);

        weaken(a).write(bas);
        weaken(b).write(bbs);

        bas.flush();
        bbs.flush();

        as.close();
        bs.close();

        final String x = as.getBuffer().toString();
        final String y = bs.getBuffer().toString();

        return x.equals(y);
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  private String ask(String cmd) {
    BufferedWriter out = null;
    BufferedReader in = null;
    Socket sock = null;
    String ret = "";
    try {
      System.out.println(server);
      sock = new Socket(server, ServerListener.PORT);
      out = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream()));
      out.write(cmd, 0, cmd.length());
      out.flush();
      in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
      int inr = in.read();
      while (inr != ';') {
        ret += Character.toString((char) inr);
        inr = in.read();
      }
    } catch (IOException io) {
      io.printStackTrace();
    } finally {
      try {
        out.close();
        in.close();
        sock.close();
      } catch (IOException io) {
        io.printStackTrace();
      }
    }

    return ret;
  }
  static void task1() throws FileNotFoundException, IOException, SQLException {
    // Read Input
    System.out.println("Task1 Started...");
    BufferedReader br = new BufferedReader(new FileReader(inputFile));
    br.readLine();
    String task1Input = br.readLine();
    br.close();
    double supportPercent =
        Double.parseDouble(task1Input.split(":")[1].split("=")[1].split("%")[0].trim());
    if (supportPercent >= 0) {
      System.out.println("Task1 Support Percent :" + supportPercent);
      // Prepare query
      String task1Sql =
          "select  temp.iname,(temp.counttrans/temp2.uniquetrans)*100 as percent"
              + " from (select i.itemname iname,count(t.transid) counttrans from trans t, items i"
              + " where i.itemid = t.itemid group by i.itemname having count(t.transid)>=(select count(distinct transid)*"
              + supportPercent / 100
              + " from trans)"
              + ") temp , (select count(distinct transid) uniquetrans from trans) temp2 order by percent";

      PreparedStatement selTask1 = con.prepareStatement(task1Sql);
      ResultSet rsTask1 = selTask1.executeQuery();

      BufferedWriter bw = new BufferedWriter(new FileWriter("system.out.1"));
      while (rsTask1.next()) {
        bw.write("{" + rsTask1.getString(1) + "}, s=" + rsTask1.getDouble(2) + "%");
        bw.newLine();
      }
      rsTask1.close();
      bw.close();
      System.out.println("Task1 Completed...\n");
    } else System.out.println("Support percent should be a positive number");
  }
  // execute and get results
  private void execute(Connection conn, String text, Writer writer, boolean commaSeparator)
      throws SQLException {

    BufferedWriter buffer = new BufferedWriter(writer);
    Statement stmt = conn.createStatement();
    stmt.execute(text);
    ResultSet rs = stmt.getResultSet();
    ResultSetMetaData metadata = rs.getMetaData();
    int nbCols = metadata.getColumnCount();
    String[] labels = new String[nbCols];
    int[] colwidths = new int[nbCols];
    int[] colpos = new int[nbCols];
    int linewidth = 1;

    // read each occurrence
    try {
      while (rs.next()) {
        for (int i = 0; i < nbCols; i++) {
          Object value = rs.getObject(i + 1);
          if (value != null) {
            buffer.write(value.toString());
            if (commaSeparator) buffer.write(",");
          }
        }
      }
      buffer.flush();
      rs.close();
    } catch (IOException ex) {
      if (Debug.isDebug()) ex.printStackTrace();
      // ok, exit from the loop
    } catch (SQLException ex) {
      if (Debug.isDebug()) ex.printStackTrace();
    }
  }
 public static void init() throws Exception {
   Properties props = new Properties();
   int pid = OSProcess.getId();
   String path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath();
   /** * Return file as string and then modify the string accordingly ** */
   String file_as_str = readFile(TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml"));
   file_as_str = file_as_str.replaceAll("newDB", "newDB_" + pid);
   String modified_file_str = modifyFile(file_as_str);
   FileOutputStream fos = new FileOutputStream(path);
   BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(fos));
   wr.write(modified_file_str);
   wr.flush();
   wr.close();
   props.setProperty("cache-xml-file", path);
   //    String tableName = "";
   //		  props.setProperty("mcast-port", "10339");
   try {
     //			   ds = DistributedSystem.connect(props);
     ds = (new ExceptionsDUnitTest("temp")).getSystem(props);
     cache = CacheFactory.create(ds);
   } catch (Exception e) {
     e.printStackTrace(System.err);
     throw new Exception("" + e);
   }
 }
Exemple #18
0
  public static void main(String[] args) {
    lineNumber = 1;

    try {
      fstream = new FileWriter("output");
      bw = new BufferedWriter(fstream);
      br = new BufferedReader(new FileReader(INPUTFILENAME));
    } catch (FileNotFoundException e) {
      System.out.println(e);
    } catch (IOException e) {
      System.out.println(e);
    }

    addNodes();

    try {
      while ((line = br.readLine()) != null) {
        task = line.substring(0, line.indexOf(":"));
        input = line.substring(line.indexOf(":") + 1);
        bw.write("Output #" + Integer.toString(lineNumber) + ": ");
        if (task.equals("findDistance")) {
          findDistance(input);
        } else if (task.equals("findShortestRoute")) {
          findShortestRoute(input);
        } else if (task.equals("findNumberofRoutes")) {
          findNumberofRoutes(input);
        }
        lineNumber++;
      }

      bw.close();
    } catch (IOException e) {
      System.out.println(e);
    }
  }
  public static void toCRAWDAD(LinkTrace links, OutputStream out, double timeMul)
      throws IOException {

    StatefulReader<LinkEvent, Link> linkReader = links.getReader();
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out));
    Map<Link, Long> activeContacts = new AdjacencyMap.Links<Long>();

    linkReader.seek(links.minTime());
    for (Link l : linkReader.referenceState()) activeContacts.put(l, links.minTime());
    while (linkReader.hasNext()) {
      for (LinkEvent lev : linkReader.next()) {
        Link l = lev.link();
        if (lev.isUp()) {
          activeContacts.put(l, linkReader.time());
        } else {
          double b = activeContacts.get(l) * timeMul;
          double e = linkReader.time() * timeMul;
          activeContacts.remove(l);
          bw.write(l.id1() + "\t" + l.id2() + "\t" + b + "\t" + e + "\n");
        }
      }
    }
    linkReader.close();
    bw.close();
  }
Exemple #20
0
  /**
   * Gera uma partícula aleatória de dimensões fixas.
   *
   * <p>Define os valores para size, maxValue, dimensions, lBest e inertia.
   *
   * @param pagesArray array com as páginas do banco de dados
   * @param size quantidade de dimensões da partícula
   */
  public Particle(int[] pagesArray, int size, int inertia, Random r) throws IOException {

    maxValue = pagesArray.length;
    dimensions = new int[size];
    velocity = new int[size];
    lBest = new int[size];
    this.inertia = inertia;
    this.rnd = r;

    for (int i = 0; i < size; i++) {

      dimensions[i] = (int) (rnd.nextFloat() * pagesArray.length);
      lBest[i] = (int) (rnd.nextFloat() * pagesArray.length);
      // System.out.println("dimensions["+i+"] : "+dimensions[i]);
    }

    File f = new File("dimensions");

    FileWriter fw = new FileWriter(f, true);
    BufferedWriter bw = new BufferedWriter(fw);
    PrintWriter pw = new PrintWriter(bw);

    pw.println("pagesArray.length " + pagesArray.length);
    for (int i = 0; i < dimensions.length; i++) {
      pw.print(dimensions[i] + " ");
    }
    pw.println();

    pw.close();
    bw.close();
    fw.close();
  }
  /**
   * piirtää reitin tiedostoon ja reittikartta taulukkoon
   *
   * @param käydytsolmut
   * @throws IOException
   */
  public void piirräreitti(PriorityQueue<Solmu> käydytsolmut) throws IOException {

    String nimi = new String("uk");
    BufferedWriter reittikarttatiedosto = new BufferedWriter(new FileWriter("uk"));
    Solmu solmu = new Solmu(0, 0, null, 0);

    while (!käydytsolmut.isEmpty()) {
      solmu = käydytsolmut.poll();

      for (int n = 0; n < kartankoko; n++) {
        for (int i = 0; i < kartankoko; i++) {
          if (solmu.x == n && solmu.y == i) {
            // reittikartta[i][n] = '-';
            reittikartta[i][n] = (char) (solmu.summaamatkat(0, solmu.annavanhempi()) + 65);
            // reittikarttatiedosto.write("-");
            reittikarttatiedosto.write('-');
          } else {
            reittikarttatiedosto.write(reittikartta[i][n]);
          }
        }
        reittikarttatiedosto.newLine();
      }
    }
    reittikarttatiedosto.close();
    tulostakartta(reittikartta);
  }
  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));

    // byte digit[]=new byte[101];
    // boolean[] check=new boolean[101];
    // int num[]=new int[99999];
    ans = 0;
    int tests = Integer.parseInt(br.readLine());
    BigInteger f[] = new BigInteger[101];

    for (int i = 1; i <= 100; i++) {
      f[i] = new BigInteger(("" + i));
    }
    for (int i = 2; i <= 100; i++) {
      f[i] = f[i].multiply(f[i - 1]);
    }

    for (int i = 0; i < tests; i++) {

      int n = Integer.parseInt(br.readLine());
      out.write("\n" + f[n].toString());
      out.flush();
    }
  }
  static void writeNewData(String datafile) {

    try {
      BufferedReader bufr = new BufferedReader(new FileReader(datafile));
      BufferedWriter bufw = new BufferedWriter(new FileWriter(datafile + ".nzf"));

      String line;
      String[] tokens;

      while ((line = bufr.readLine()) != null) {

        tokens = line.split(" ");
        bufw.write(tokens[0]);
        for (int i = 1; i < tokens.length; i++) {

          Integer index = Integer.valueOf(tokens[i].split(":")[0]);
          if (nnzFeas.contains(index)) {
            bufw.write(" " + tokens[i]);
          }
        }
        bufw.newLine();
      }
      bufw.close();
      bufr.close();

    } catch (Exception e) {
      e.printStackTrace();
      System.exit(0);
    }
  }
Exemple #24
0
  public void save() {
    BufferedWriter sourceFile = null;

    try {
      String sourceText = sourceArea.getText();

      String cleanText = cleanupSource(sourceText);

      if (cleanText.length() != sourceText.length()) {
        sourceArea.setText(cleanText);

        String message =
            String.format(
                "One or more invalid characters at the end of the source file have been removed.");
        JOptionPane.showMessageDialog(this, message, "ROPE", JOptionPane.INFORMATION_MESSAGE);
      }

      sourceFile = new BufferedWriter(new FileWriter(sourcePath, false));
      sourceFile.write(cleanText);

      setSourceChanged(false);

      setupMenus();
    } catch (IOException ex) {
      ex.printStackTrace();
    } finally {
      if (sourceFile != null) {
        try {
          sourceFile.close();
        } catch (IOException ignore) {
        }
      }
    }
  }
Exemple #25
0
 private void setFileText(File file, String text) throws Exception {
   BufferedWriter bw =
       new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
   bw.write(text, 0, text.length());
   bw.flush();
   bw.close();
 }
Exemple #26
0
 /**
  * write categories to AIMLIF file
  *
  * @param cats array list of categories
  * @param filename AIMLIF filename
  */
 public void writeIFCategories(ArrayList<Category> cats, String filename) {
   // System.out.println("writeIFCategories "+filename);
   BufferedWriter bw = null;
   File existsPath = new File(aimlif_path);
   if (existsPath.exists())
     try {
       // Construct the bw object
       bw = new BufferedWriter(new FileWriter(aimlif_path + "/" + filename));
       for (Category category : cats) {
         bw.write(Category.categoryToIF(category));
         bw.newLine();
       }
     } catch (FileNotFoundException ex) {
       ex.printStackTrace();
     } catch (IOException ex) {
       ex.printStackTrace();
     } finally {
       // Close the bw
       try {
         if (bw != null) {
           bw.flush();
           bw.close();
         }
       } catch (IOException ex) {
         ex.printStackTrace();
       }
     }
 }
Exemple #27
0
 public static void outputTaskDetail(int numCtrls, int partSize, int numJobsPerPart) {
   try {
     bwTaskDetail.write(
         "JobId\tStartTime\tSubmissionTime\t" + "ExecuteTime\tFinishTime\tResultBackTime\r\n");
     for (int i = 0; i < numCtrls; i++) {
       String ctrlId = "node-" + Integer.toString(i * partSize);
       for (int j = 0; j < numJobsPerPart; j++) {
         String jobId = ctrlId + " " + Integer.toString(j);
         Job job = jobMetaData.get(jobId);
         long startTime;
         long submitTime;
         long exeTime;
         long finTime;
         long backTime;
         bwTaskDetail.write(
             jobId
                 + "\t"
                 + job.startTime
                 + "\t"
                 + job.submitTime
                 + "\t"
                 + job.exeTime
                 + "\t"
                 + job.finTime
                 + "\t"
                 + job.backTime
                 + "\r\n");
       }
     }
     bwTaskDetail.flush();
     bwTaskDetail.close();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
  public void write(OutputStream os) throws Exception {
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));

    String str = toString();
    bw.write(str, 0, str.length());
    bw.newLine();
    bw.close();
  }
 public void writeToFile(String outfilename, String script) {
   try {
     BufferedWriter out = new BufferedWriter(new FileWriter(outfilename));
     out.write(script);
     out.close();
   } catch (IOException e) {
   }
 }
  public void writeResults(String outputFile) {

    try {
      // Create file
      FileWriter fStream = new FileWriter(outputFile);
      BufferedWriter out = new BufferedWriter(fStream);

      out.write(
          "Attribute Type"
              + SEPARATOR
              + "numberOfDiffValues"
              + SEPARATOR
              + "min"
              + SEPARATOR
              + "max"
              + SEPARATOR
              + "Example\n");
      for (Map.Entry<String, Set<String>> entry : attrByValue.entrySet()) {
        Set<String> attrValues = entry.getValue();
        String lineToWrite = entry.getKey();

        Collections.max(attrValues);

        String sampleValues = "";
        int maxNumberOfSampleValues = 0;

        for (String s : attrValues) {
          sampleValues = sampleValues + " " + s;
          if (maxNumberOfSampleValues > MAX_EXAMPLE_COUNT) break;
          maxNumberOfSampleValues++;
        }

        String max = Collections.max(attrValues);
        String min = Collections.min(attrValues);

        lineToWrite =
            lineToWrite
                + SEPARATOR
                + attrValues.size()
                + SEPARATOR
                + max
                + SEPARATOR
                + min
                + SEPARATOR
                + sampleValues.trim();

        out.write(lineToWrite + "\n");
      }

      out.flush();
      // Close the output stream
      out.close();
    } catch (Exception e) { // Catch exception if any
      System.err.println("Error: " + e.getMessage());
    }
  }