mpierse пре 7 година
родитељ
комит
d2ec41ae42

+ 3
- 3
src/main/java/rocks/zipcode/AlphaCharDocument.java Прегледај датотеку

@@ -8,13 +8,13 @@ import java.util.Scanner;
8 8
  */
9 9
 public class AlphaCharDocument extends Document {
10 10
 
11
-//private String fileName;
11
+
12 12
 private File file;
13
-//private FileWriter fw = new FileWriter(file);
13
+
14 14
 
15 15
     public AlphaCharDocument(String fileName) throws IOException {
16 16
         super(fileName);
17
-       this.file = new File(fileName);
17
+        this.file = new File(fileName);
18 18
        // this.fileName = fileName;
19 19
        // fw = new FileWriter(file);
20 20
     }

+ 23
- 4
src/main/java/rocks/zipcode/Document.java Прегледај датотеку

@@ -4,30 +4,49 @@ import java.io.*;
4 4
 import java.nio.file.Files;
5 5
 import java.util.Arrays;
6 6
 import java.util.List;
7
+import java.util.Scanner;
7 8
 
8 9
 /**
9 10
  * @author leon on 16/11/2018.
10 11
  */
11 12
 public class Document implements DocumentInterface {
12 13
 
13
-    private final FileWriter fileWriter;
14
-    private final File file;
14
+    private final FileWriter fw;
15
+   // private final File file;
15 16
 
16 17
     public Document(String fileName) throws IOException {
17 18
         this(new File(fileName));
18 19
     }
19 20
 
20 21
     public Document(File file) throws IOException {
21
-        this.file = file;
22
-        this.fileWriter = new FileWriter(file);
22
+      //  this.file = file;
23
+        this.fw = new FileWriter(file);
23 24
     }
24 25
 
25 26
     @Override
26 27
     public void write(String contentToBeWritten) {
28
+        try {
29
+            fw.write(contentToBeWritten);
30
+            fw.close();
31
+        } catch (IOException ex) {
32
+            ex.printStackTrace();
33
+        }
27 34
     }
28 35
 
29 36
     @Override
30 37
     public void write(Integer lineNumber, String valueToBeWritten) {
38
+//        Scanner scanner = null;
39
+//        try {
40
+//            scanner = new Scanner(file);
41
+//        } catch (FileNotFoundException e) {
42
+//            e.printStackTrace();
43
+//        }
44
+//        StringBuilder sb = new StringBuilder();
45
+//        while(scanner.hasNextLine()){
46
+//            sb.append(scanner.nextLine());
47
+//        }
48
+//        String content = sb.toString();
49
+
31 50
     }
32 51
 
33 52
     @Override