Created
April 27, 2015 22:10
-
-
Save pumpkincouture/f4430a8c496efd0971bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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