/**
     * 文字列のMS932でのバイト長を取得する
     * @param target バイト長を取得したい文字列
     * @return 文字列のバイト長
     */
    public static int getByteLength(String target) {
        int result = 0;
        try {
            result = target.getBytes("MS932").length;
        }
        catch (UnsupportedEncodingException e) {
            // MS932がサポートされていないことはありえないので、ここには来ないはず
        }
        return result;
    }
AND