示例#1
0
  public void writeIndex(String location) {

    System.out.println("Writing index at: " + location);

    ObjectOutputStream objectOutputStream = null;

    try {

      File outputFile = new File(location);
      if (!outputFile.exists()) {
        outputFile.getParentFile().mkdirs();
        outputFile.createNewFile();
      }

      OutputStream file = new FileOutputStream(outputFile);
      BufferedOutputStream buffer = new BufferedOutputStream(file);
      objectOutputStream = new ObjectOutputStream(buffer);
      objectOutputStream.writeObject(tokenCountMap);
      objectOutputStream.writeObject(references);
    } catch (IOException ex) {
      System.out.println(
          "\nError writing index for " + author.getName() + " at location " + location);
    } finally {
      if (objectOutputStream != null)
        try {
          objectOutputStream.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
    }
  }
示例#2
0
 public String getAuthorName() {
   return author.getName();
 }