List of usage examples for org.eclipse.jgit.lib Repository close
@Override public void close()
Decrement the use count, and maybe close resources.
From source file:uk.ac.cam.UROP.twentyfourteen.database.GitDb.java
/** * getFileByCommitSHA/* w ww. j a v a2 s . co m*/ * * This method will access the git repository given a particular SHA and * will attempt to locate a unique file and return a bytearrayoutputstream * of the files contents. * * @param SHA * to search in. * @param Full * file path to search for e.g. /src/filename.json * @return the ByteArrayOutputStream - which you can extract the file * contents via the toString method. * @throws IOException * @throws UnsupportedOperationException * - This method is intended to only locate one file at a time. * If your search matches multiple files then this exception * will be thrown. */ public ByteArrayOutputStream getFileByCommitSHA(String sha, String fullFilePath) throws IOException, UnsupportedOperationException { if (null == sha || null == fullFilePath) return null; ObjectId objectId = this.findGitObject(sha, fullFilePath); if (null == objectId) { return null; } Repository repository = gitHandle.getRepository(); ObjectLoader loader = repository.open(objectId); ByteArrayOutputStream out = new ByteArrayOutputStream(); loader.copyTo(out); repository.close(); return out; }