String.substring(index)已在调试模式下停止了我的线程

时间:2010-05-10 12:38:26

标签: java string eclipse j2mepolish java-wireless-toolkit

我使用wtk2.5.2_01在eclipse 3.4.2中使用j2me polish 2.0.7。 我创建了绘制文本的控件:normal,bold和italic。

下面的代码是解析原始文本,并搜索*和_符号,如果找到,则添加到绘制矢量文本和抽屉,它只是在第二次到达第58行后停止:
String test = new String(raw_text_buff.substring(iter));
它在raw_text_buff.substring(iter)中停止,仅在调试模式下。

原始文字是:bla bla bla *1000* bla bla

完整代码:

private String raw_text = "bla bla bla *1000* bla bla";
Vector draw_items = null;

private void prepareText()
{
    char open_char = 0; 
    int open_pos = 0;
    Object []param = null;
    StringBuffer sb = new StringBuffer();
    String raw_text_buff = new String(raw_text);
    int iter = 0;
    boolean was_reset = false; 
    while(true)
    {
        char c = raw_text_buff.charAt(iter);



        if(iter == raw_text_buff.length() || c == '*' || c == '_')
        {
            if(sb.length() > 0) 
            {
                BmFont viewer = null;
                String str = sb.toString();

                if(open_char == '*' && null != bm_strong)
                {
                    viewer = bm_strong.getViewer(str);
                }else
                if(open_char == '_' && null != bm_italic)
                {
                    viewer = bm_italic.getViewer(str);
                }else if(null != bm_normal)
                {
                    viewer = bm_normal.getViewer(str);
                }else
                {

                }

                param = new Object[2];

                param[0] = str;
                param[1] = viewer;

                if(null == draw_items)
                    draw_items = new Vector();

                draw_items.addElement(param);

                sb = new StringBuffer();

                if(open_char == 0 && (c == '*' || c=='_'))
                    open_char = c; 
                else
                    open_char = 0; 

                String test = new String(raw_text_buff.substring(iter)); // stucks here.
                raw_text_buff = test;
                iter = 0;
                was_reset = true;
            }else
            {
                open_char = c;
            }


            if(iter == raw_text_buff.length())
                break;
        }else
        {
            sb.append(c);

        }

        ++iter;
    }


}

我做错了什么?

0 个答案:

没有答案