Commit 8ace1e39f78815c97b90d767b6e9e4ae699597e8

Authored by Maryna German Bjørnstrøm
1 parent 01400a90

referansenliste.txt

Showing 2 changed files with 13 additions and 18 deletions   Show diff stats
referanselisten.txt 0 → 100644
  1 +https://www.caveofprogramming.com/java/java-file-reading-and-writing-files-in-java.html
  2 +http://kark.hin.no/opsys/tanenbaum/java/ExecutableFiles.java
  3 +http://kark.hin.no/sikkerhet/filehash/oblig5_tips.html
0 4 \ No newline at end of file
... ...
src/hashObl5/ExecutableFiles.java
... ... @@ -85,23 +85,17 @@ public class ExecutableFiles extends Object {
85 85  
86 86 try {
87 87  
88   - FileReader fileReader =
89   - new FileReader(fileName);
90   -
91   -
92   - BufferedReader bufferedReader =
93   - new BufferedReader(fileReader);
94   -
95   - while((line = bufferedReader.readLine()) != null) {
96   - data.append(line);
97   - }
  88 + FileReader fileReader = new FileReader(fileName);
  89 +
  90 + BufferedReader bufferedReader = new BufferedReader(fileReader);
  91 +
  92 + while((line = bufferedReader.readLine()) != null) {
  93 + data.append(line);
  94 + }
98 95  
99   -
100   - FileWriter fileWriter =
101   - new FileWriter(fileName);
  96 + FileWriter fileWriter = new FileWriter(fileName);
102 97  
103   - BufferedWriter bufferedWriter =
104   - new BufferedWriter(fileWriter);
  98 + BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
105 99  
106 100 data.append("\n");
107 101 data.append(absolutePath + "," + apache_sha256);
... ... @@ -112,9 +106,7 @@ public class ExecutableFiles extends Object {
112 106 bufferedReader.close();
113 107 }
114 108 catch(IOException ex) {
115   - System.out.println("Error writing to file '"
116   - + fileName + "'");
117   -
  109 + System.out.println("Error writing to file '" + fileName + "'");
118 110 }
119 111 }
120 112  
... ...