2009-08-31 2 views

답변

2

BlackBerry에서 우리는 두 개의 압축 표준 인 GZipZLib을 사용할 수 있습니다. 하나를 선택한 다음 파일을 압축하고 프로젝트에 추가하십시오. 그러면 리소스로 열 수 있습니다. 그런 다음 GZIPInputStream 또는 ZLibInputStream으로 압축을 해제하십시오.

예 (프로젝트 부착 test.gz에서 압축 해제 및 인쇄 텍스트) :

try 
{ 
    InputStream inputStream = getClass().getResourceAsStream("test.gz"); 
    GZIPInputStream gzis = new GZIPInputStream(inputStream); 
    StringBuffer sb = new StringBuffer(); 

    int i; 
    while ((i = gzis.read()) != -1)   
    { 
     sb.append((char)i); 
    } 

    String data = sb.toString(); 
    add(new RichTextField(data)); 
    gzis.close(); 
} 
catch(IOException ioe) 
{ 
    //do something here 
}