KXMl中解决中文乱码问题

public void verifyCredentials() throws Exception
  {     
    InputStream is ;
    HttpConnection hc = (HttpConnection) Connector.open(url);    
       try
       { 
       int stateCode = hc.getResponseCode();   
    if(stateCode==200)
       {
        is = hc.openInputStream();
        InputStreamReader in = new InputStreamReader(is,"UTF-8");
        XmlParser parser = new XmlParser(in);
          boolean parsing = true;       //判断是否到达最后一个document标签
               while(parsing)
          {
          ParseEvent event = parser.read();//
          switch(event.getType())
          {
              case Xml.START_TAG :       //处理开始标签tag
                   System.out.println("处理开始标签");
                   System.out.println("Tagname--"+((StartTag)event).getName()); //                
                           break;
             case Xml.END_TAG :       //处理结束标签tag
                  System.out.println("处理结束标签111");
                  System.out.println("Tagname--"+event.toString());
                  break;
            case Xml.END_DOCUMENT :       //处理开始标签tag
                   System.out.println("结束处理标签,退出程序222222");
                   System.out.println("Tagname--"+event.toString());
                   parsing = false;
                           break;   
           case Xml.TEXT :       //处理内容   
           System.out.println("内容---"+event.getText());              
                       break; 
                  }          
          }         
      }
       else if(stateCode==401)
       {
      System.out.println("操作失败");
       }
     }
     catch (RuntimeException e)
     {
     System.out.println(e.getMessage());
     }
     catch (Exception e)
     {
     System.out.println(e.getMessage());
     }
    finally
    {   
    if(null != hc){
      hc.close();
      hc = null;
       }
     }     
    }

你可能感兴趣的:(中文乱码,职场,JavaME,休闲,kxml)