2012-02-19 3 views
0

Java 프로그램에서 ODS 스프레드 시트를 출력으로 생성하고 있습니다. 현재 동일한 테스트 케이스를 설정하려고합니다. 이를 위해서는 예상 결과와 실제 결과를 비교해야합니다. 현재 ODFToolkit을 사용하여 문서를 만듭니다.Java에서 프로그래밍 방식으로 두 개의 ods 문서를 비교하는 방법은 무엇입니까?

Java 프로그램에서 두 스프레드 시트 (예상 및 실제)를 비교하려면 어떻게합니까?

사람이 솔루션을 필요로하는 경우에
+0

감사하고, leppie! –

답변

0

, 여기에 추가 된 태그에 대한

public static boolean contentsAreIdentical(OdfSpreadsheetDocument document1, OdfSpreadsheetDocument document2) { 
    try { 
     ByteArrayInputStream bis1 = (ByteArrayInputStream) document1.getContentStream(); 
     ByteArrayInputStream bis2 = (ByteArrayInputStream) document2.getContentStream(); 

     if(bis1.available() != bis2.available()) { 
      return false; 
     } 

     while(true){ 
      int a = bis1.read(); 
          int b = bis2.read(); 
          if(a != b){ 
            return false; 
          } 
          if(a == -1){ 
            return true; 
          } 
        } 
    } catch (Exception e) { 
     //Do something with exception 
    } 
    return false; 
}