Skip to content

Instantly share code, notes, and snippets.

@pumpkincouture
Created April 27, 2015 22:10
Show Gist options
  • Save pumpkincouture/f4430a8c496efd0971bf to your computer and use it in GitHub Desktop.
Save pumpkincouture/f4430a8c496efd0971bf to your computer and use it in GitHub Desktop.
public class FileManager {
private File filePath;
private DataOutputStream out;
public FileManager(File filePath, DataOutputStream out) {
this.filePath = filePath;
this.out = out;
}
public String getFileContents() {
String fileContent = "";
try {
BufferedReader br = new BufferedReader(new FileReader(filePath.toString()));
String endOfLines = null;
while ((endOfLines = br.readLine()) != null) {
fileContent += endOfLines + "\r\n";
}
br.close();
} catch (IOException e) {
e.printStackTrace();
}
return fileContent;
}
public void getImageContents() {
try {
InputStream file = new FileInputStream(filePath.toString());
byte[] bytes = Files.readAllBytes(filePath.toPath());
while (file.read( bytes ) > 0) {
out.write(bytes);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment