-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsciiFileWriter.java
More file actions
71 lines (60 loc) · 1.59 KB
/
Copy pathAsciiFileWriter.java
File metadata and controls
71 lines (60 loc) · 1.59 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package gov.ca.water.gisutil;
import java.io.*;
import java.util.Vector;
import org.picocontainer.defaults.ObjectReference;
/**
*
*/
public class AsciiFileWriter{
FileWriter _aOutFile = null;
BufferedWriter _asciiOut = null;
String _filename;
Vector _allLines = null;
public AsciiFileWriter(String filename){
_allLines = new Vector();
_filename=filename;
open();
}//constructor
public AsciiFileWriter(String filename, boolean append){
_allLines = new Vector();
_filename=filename;
if(append){
openAppend();
}else{
open();
}
}
protected void openAppend(){
try{
_aOutFile = new FileWriter(_filename,true);
_asciiOut = new BufferedWriter(_aOutFile);
}catch(IOException e){
System.out.println("error occurred while opening file "+_filename + e.getMessage());
}
}
protected void open(){
try{
_aOutFile = new FileWriter(_filename);
_asciiOut = new BufferedWriter(_aOutFile);
}catch(IOException e){
System.out.println("error occurred while opening file "+_filename + e.getMessage());
}
}//open
public void writeLine(String line){
try{
_asciiOut.write(line);
_asciiOut.newLine();
}catch(Exception e){
System.out.println("exception caught in AsciiFileWriter.write while reading ");
System.out.println("file "+_filename+e.getMessage());
}
}//writeLine
public void close(){
try{
_asciiOut.close();
}catch(java.io.IOException e){
System.out.println("exception caught while trying to close file: "+
_filename+e.getMessage());
}
}//close
}//AsciiFileWriter