2012-01-11 10 views
-3

を投げているを使用して、それがラインeditor.addFile(textfile, null, -1);私はエディタを使用して、リポジトリ内のすべてのファイルを追加することはできませんよSVNリポジトリにファイルを追加することができませんキットおよび以下のコードjava.lang.NullPointerExceptionが

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 - はい、どこに定義されていますか?私たちが知っている限り、それは「ヌル」です。 –

関連する問題