Java FileReader Read loadIndex(File root_)

Here you can find the source of loadIndex(File root_)

Description

Loads an index (Hashtable) from a file.

License

Open Source License

Parameter

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

Return

The indextable.

Declaration

public static Hashtable loadIndex(File root_) throws IOException 

Method Source Code


//package com.java2s;
/*/*from w  ww  .  j a  v a2  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.Hashtable;

public class Main {
    /**
     * Loads an index (Hashtable) from a file.
     * @param root_ The file where the index is stored in.
     * @return The indextable.
     * @exception IOException If an internal error prevents the file
     *            from being read.
     */
    public static Hashtable loadIndex(File root_, String name) throws IOException {
        File indexfile = new File(root_, name);
        Hashtable index = new Hashtable();
        if (indexfile.exists()) {
            LineNumberReader in = new LineNumberReader(new FileReader(indexfile));
            while (in.ready())
                index.put(in.readLine(), new Long(in.readLine()));
            in.close();
        }
        return index;
    }

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

Related

  1. load(String filename)
  2. load(String fileName, Class klass)
  3. loadJSON(File file)
  4. loadKeggInteractions(String species, String location)
  5. readFile(File f)
  6. readFile(File f)