com.l2jfree.security.HexID.java Source code

Java tutorial

Introduction

Here is the source code for com.l2jfree.security.HexID.java

Source

/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program 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 General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.l2jfree.security;

import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Properties;

import org.apache.commons.io.IOUtils;

/**
 * @deprecated Legacy class
 */
@Deprecated
public final class HexID {
    /**
     * Save hexadecimal ID of the server in the properties file.
     * 
     * @param string (String) : hexadecimal ID of the server to store
     * @param fileName (String) : name of the properties file
     */
    public static void saveHexid(String string, String fileName) {
        OutputStream out = null;
        try {
            out = new FileOutputStream(fileName);

            final Properties hexSetting = new Properties();
            hexSetting.setProperty("HexID", string);
            hexSetting.store(out, "the hexID to auth into login");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            IOUtils.closeQuietly(out);
        }
    }

    /**
     * Save hexadecimal ID of the server in the properties file.
     * 
     * @param serverId game server ID
     * @param hexId (String) : hexadecimal ID of the server to store
     * @param fileName (String) : name of the properties file
     */
    public static void saveHexid(int serverId, String hexId, String fileName) {
        OutputStream out = null;
        try {
            out = new FileOutputStream(fileName);

            final Properties hexSetting = new Properties();
            hexSetting.setProperty("ServerID", String.valueOf(serverId));
            hexSetting.setProperty("HexID", hexId);
            hexSetting.store(out, "the hexID to auth into login");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            IOUtils.closeQuietly(out);
        }
    }
}