Java FileWriter Write saveIndex(File root_, Hashtable index)

Here you can find the source of saveIndex(File root_, Hashtable index)

Description

Saves an index (Hashtable) to a file.

License

Open Source License

Parameter

Parameter Description
root_ The file where the index is stored in.
index The indextable.

Declaration

public static void saveIndex(File root_, Hashtable index) throws IOException 

Method Source Code


//package com.java2s;
/*//from   ww w  .ja  va2  s.  c  om
    
    
This file is part of WOW! based on AHA! (Adaptive Hypermedia for All) which is free software (GNU General Public License) developed by Paul De Bra - Eindhoven University of Technology and University
    
WOW! is also open source software; 
    
    
*/

import java.io.*;
import java.util.Enumeration;
import java.util.Hashtable;

public class Main {
    /**
     * Saves an index (Hashtable) to a file.
     * @param root_ The file where the index is stored in.
     * @param index The indextable.
     * @exception IOException If an internal error prevents the file
     *            from being written.
     */
    public static void saveIndex(File root_, String name, Hashtable index) throws IOException {
        File indexfile = new File(root_, name);
        PrintWriter out = new PrintWriter(new FileWriter(indexfile));
        Enumeration keys = index.keys();
        String key = null;
        while (keys.hasMoreElements()) {
            key = (String) keys.nextElement();
            out.println(key);
            out.println((Long) index.get(key));
        }
        out.close();
    }

    /**
     * Saves an index (Hashtable) to a file.
     * @param root_ The file where the index is stored in.
     * @param index The indextable.
     * @exception IOException If an internal error prevents the file
     *            from being written.
     */
    public static void saveIndex(File root_, Hashtable index) throws IOException {
        saveIndex(root_, "index", index);
    }
}

Related

  1. saveFileFromString(File file, String encoding, String content)
  2. saveFiles(final List contents, final File outputDirectory, final String outputName, final String fileExtension)
  3. saveFlows(Map differences, String file)
  4. saveFormedClustersToFile(Vector names, Collection> clusters, String filename)
  5. saveGraph(List> graph, String sFileName)
  6. saveInputStreamInFile(InputStream stream, FileWriter f)
  7. saveIntegerNodes2File(Integer[] nodes, String fileName)
  8. saveIntNodes2File(int[] nodes, String fileName)
  9. saveList(String listName, Set list)