2012-01-11 4 views
-3

을 던지고있다 editor.addFile(textfile, null, -1);는 저장소와 아래의 코드는 java.lang.NullPointerException이

try { 
    url = "https://XXX.yyy.zzzz"; 
    SVNRepository repository = null; 
    String name = "testuser"; 
    String password = "testuserpassword"; 
    repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(url)); 
    ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(name, password); 
    repository.setAuthenticationManager(authManager); 
    System.out.println(repository.getLatestRevision()); 

    SVNClientInterface client = SVNClientImpl.newInstance(); 
} catch (Exception e) { 
    System.out.println("error"); 
}    

try { 
    ISVNEditor editor = repository.getCommitEditor("This is a log message.", new CommitMediator()); 

    editor.openRoot(-1); 
    System.out.println("in DAV"); 
    editor.addFile(textfile, null, -1); 
    editor.addFile("file1.txt", null, -1);  
    editor.applyTextDelta("file1.txt", null); 
    OutputStream os=null; 
    os.close(); 
    editor.textDeltaEnd(file1.txt); 
    editor.closeFile(file1.txt, null); 
    editor.closeEdit(); 
} catch(Exception e) { 
    System.out.println(e); 
} 
+0

편집기를 사용하여 저장소에 파일을 추가 할 수 없으며 "editor.addFile (textfile, null, -1); 줄의 java.lang.NullPointerException 예외가 발생합니다."감사의 전한 – user1118693

+0

'os. close();'OutputStream os = null; 다음에'NullPointerException'을 의미합니다. – javanna

+0

log4j 또는 로깅을 사용하지 않으려면 적어도'System.out.println (e);'를'e.printStackTrace();'로 바꾸십시오! – javanna

답변

0
editor.addFile(textfile, null, -1); 

textfile은 무엇입니까?

OutputStream os=null; 
os.close(); 

지금 무슨 일이 일어나고 있는지 생각해 볼 수 있습니다.

+0

"textfile"은 리포지토리에 추가하려는 텍스트 파일의 이름입니다. – user1118693

+0

@ user1118693 - 네,하지만 정의 된 위치는 어디입니까? 우리 모두 알고 있듯이, 그것은'null'입니다. –

관련 문제