Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
    
 This file is part of GALE (Generic Adaptation Language and Engine).
    
 GALE is free software: you can redistribute it and/or modify it under the 
 terms of the GNU Lesser General Public License as published by the Free 
 Software Foundation, either version 3 of the License, or (at your option) 
 any later version.
    
 GALE is distributed in the hope that it will be useful, but WITHOUT ANY 
 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 
 more details.
    
 You should have received a copy of the GNU Lesser General Public License
 along with GALE. If not, see <http://www.gnu.org/licenses/>.
    
 */

import java.io.File;

import java.io.FileWriter;
import java.io.IOException;

import java.io.PrintWriter;

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);
    }
}