Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. reading (which is ok ill give it that
  2. public static String read(String folderName, String file, int lineNumber) {
  3. String read = null;
  4. try {
  5. in = new BufferedReader(new FileReader(folderName + "/" + file));
  6. while (lineNumber > 0) {
  7. read = in.readLine();
  8. lineNumber--;
  9. }
  10. in.close();
  11. } catch (Exception e) {
  12. System.err.println(e);
  13. }
  14. return read;
  15. }
  16.  
  17. writing (which is very annoying considering you cant write to a specific line. it goes down the page and whatever line comes first it writes to)
  18. public static void write(String folderName, String file, String outString, boolean clear, boolean newLine) {
  19. try {
  20. if (!clear) {
  21. out = new BufferedWriter(new FileWriter(folderName + "/" + file, true));
  22. } else {
  23. out = new BufferedWriter(new FileWriter(folderName + "/" + file));
  24. }
  25. out.write(outString);
  26. if (newLine) {
  27. out.newLine();
  28. }
  29. out.close();
  30. } catch (Exception e) {
  31. System.err.println(e);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement