2012-01-11 52 views
-3

我不能使用編輯器,它是在拋繩一個java.lang.NullPointerException例外添加任何服務器中的資源editor.addFile(textfile, null, -1);使用SVN套件無法添加文件存儲庫和下面的代碼是投擲顯示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 2012-01-11 04:22:09

+0

'os。 close();在'OutputStream os = null;'之後'肯定意味着'NullPointerException'。 – javanna 2012-01-11 12:49:41

+0

如果你不想使用log4j或其他東西進行日誌記錄,請至少用'e.printStackTrace();'替換'System.out.println(e);'! – javanna 2012-01-11 12:51:12

回答

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

什麼是textfile

OutputStream os=null; 
os.close(); 

可能想考慮一下發生了什麼。

+0

「textfile」是我想要添加到存儲庫的文本文件的名稱 – user1118693 2012-01-11 07:34:18

+0

@ user1118693 - 是的,但它在哪裏定義?對於我們所知的全部,它是'空'。 – 2012-01-11 14:14:51

相關問題