Created
June 29, 2013 00:50
-
-
Save jab416171/5889173 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Snippet> listSnippets() throws IOException { | |
verifyRootDirectoryExists(); | |
File[] files = DIRECTORY.listFiles(new FileFilter() { | |
public boolean accept(File file) { | |
return file.isFile() && !file.isHidden(); | |
} | |
}); | |
List<Snippet> result = Collections.emptyList(); | |
if(files != null) { | |
result = new ArrayList<Snippet>(files.length); | |
for (File file : files) { | |
if(!file.getName().endsWith(".txt")) continue; | |
Snippet snippet = new Snippet(file); | |
snippet.setTitle("untitled"); | |
for (File title : files) { | |
if(!title.getName().endsWith(".title")) continue; | |
if(file.getName().substring(0, file.getName().length() - ".txt".length()).equals(title.getName().substring(0, title.getName().length() - ".title".length()))) { | |
snippet.setTitle(FileUtils.readFileToString(title, CodeSnippetAction.UTF_8)); | |
} | |
} | |
result.add(0, snippet); | |
} | |
} | |
Collections.sort(result); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment