Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.DecimalFormat;

public class Main {

    protected static final String encodingUTF8andSignPrefix(byte[] src, int srart, int length) throws Exception {
        byte[] b = new String(src, srart, length, "euc-kr").getBytes("utf-8");
        String str = new String(b).trim();
        str = str.substring(searchChar(str));
        DecimalFormat f = new DecimalFormat("###,###,###");
        f.setPositivePrefix("+");
        f.setNegativePrefix("-");
        return f.format(Double.parseDouble(str));
    }

    public static int searchChar(String str) {
        char[] c = str.toCharArray();
        int i = 0;
        for (i = 0; i < c.length; i++) {
            if (!Character.isDigit(c[i]))
                return i;
        }
        return 0;
    }

    public static boolean isDigit(String str) {
        char[] c = str.toCharArray();
        if (str.equals(""))
            return false;
        for (int i = 0; i < c.length; i++) {
            if (!Character.isDigit(c[i]))
                return false;
        }
        return true;
    }
}