Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.UnsupportedEncodingException;

public class Main {

    public static int getTextLengthes(String str) {
        int number = getTextLength(str);
        int length = number / 2;
        if (number % 2 != 0) {
            length += 1;
        }
        str = null;
        return length;
    }

    public static int getTextLength(String str) {
        int length = 0;
        try {
            str = new String(str.getBytes("GBK"), "ISO8859_1");
            length = str.length();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return length;
    }
}