-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmdWrite.java
More file actions
34 lines (31 loc) · 829 Bytes
/
cmdWrite.java
File metadata and controls
34 lines (31 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* cmdWrite.java
*
* Created by William Tyas
* 11/20/17
*
* This command writes commands to a file.
*/
import java.util.*;
import java.io.*;
public class cmdWrite extends base {
public cmdWrite(Scanner line, Database db, LinkedList<String> errorsList) {
run(line, db, errorsList);
}
public void run(Scanner line, Database db, LinkedList<String> errorsList) {
try {
String fileName = nextSymbol(line);
FileOutputStream outFile = new FileOutputStream(fileName, true);
PrintStream output = new PrintStream(outFile);
while (line.hasNext()) {
output.print(line.next() + " ");
}
output.println();
output.close();
outFile.close();
} catch (FileNotFoundException f) {
errorsList.add("ERROR: FILE NOT FOUND");
} catch (IOException io) {
errorsList.add("ERROR: IO EXCEPTION");
}
}
}