Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String processHexString(String inputString) {
        StringBuilder outPutString = new StringBuilder("");
        String temp = "";
        int index = inputString.indexOf("%");
        while (index > -1) {
            temp = inputString.substring(index + 1, index + 3);
            outPutString = outPutString.append(inputString.substring(0, index)).append(convertHexToChar(temp));
            inputString = inputString.substring(index + 3);
            index = inputString.indexOf("%");
        }
        return outPutString.toString();
    }

    private static String convertHexToChar(String hexchar) {
        try {
            int val = Integer.parseInt(hexchar, 16);
            Character charVal = Character.valueOf((char) val);
            return charVal.toString();
        } catch (Exception e) {
        }
        return hexchar;
    }
}