123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package rocks.zipcode;
  2. import java.io.*;
  3. import java.nio.file.Files;
  4. import java.util.Arrays;
  5. import java.util.List;
  6. import java.util.Scanner;
  7. /**
  8. * @author leon on 16/11/2018.
  9. */
  10. public class Document implements DocumentInterface {
  11. private final FileWriter fw;
  12. // private final File file;
  13. public Document(String fileName) throws IOException {
  14. this(new File(fileName));
  15. }
  16. public Document(File file) throws IOException {
  17. // this.file = file;
  18. this.fw = new FileWriter(file);
  19. }
  20. @Override
  21. public void write(String contentToBeWritten) {
  22. try {
  23. fw.write(contentToBeWritten);
  24. fw.close();
  25. } catch (IOException ex) {
  26. ex.printStackTrace();
  27. }
  28. }
  29. @Override
  30. public void write(Integer lineNumber, String valueToBeWritten) {
  31. // Scanner scanner = null;
  32. // try {
  33. // scanner = new Scanner(file);
  34. // } catch (FileNotFoundException e) {
  35. // e.printStackTrace();
  36. // }
  37. // StringBuilder sb = new StringBuilder();
  38. // while(scanner.hasNextLine()){
  39. // sb.append(scanner.nextLine());
  40. // }
  41. // String content = sb.toString();
  42. }
  43. @Override
  44. public String read(Integer lineNumber) {
  45. return null;
  46. }
  47. @Override
  48. public String read() throws FileNotFoundException {
  49. return null;
  50. }
  51. @Override
  52. public void replaceAll(String stringToReplace, String replacementString) {
  53. }
  54. @Override
  55. public void overWrite(String content) {
  56. }
  57. public List<String> toList() {
  58. return null;
  59. }
  60. @Override
  61. public File getFile() {
  62. return null;
  63. }
  64. @Override
  65. public String toString() {
  66. return null;
  67. }
  68. }