Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/***********************************************************************************************************************
 * Copyright (c) 2008 empolis GmbH and brox IT Solutions GmbH. All rights reserved. This program and the accompanying
 * materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: Daniel Stucky (empolis GmbH) - initial API and implementation
 **********************************************************************************************************************/

public class Main {
    /**
     * Hex format.
     * 
     * @param i
     *          a int
     * @param j
     *          a int
     * @return a String
     */
    private static String hexFormat(int i, int j) {
        final String s = Integer.toHexString(i);
        return padHex(s, j) + s;
    }

    /**
     * Pad Hex.
     * 
     * @param s
     *          a String
     * @param i
     *          a int
     * @return a String
     */
    private static String padHex(String s, int i) {
        final StringBuffer tmpBuffer = new StringBuffer();
        if (s.length() < i) {
            for (int j = 0; j < i - s.length(); j++) {
                tmpBuffer.append('0');
            }
        }
        return tmpBuffer.toString();
    }
}