01: /* Soot - a J*va Optimization Framework
02: * Copyright (C) 2003 Jennifer Lhotak
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the
16: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17: * Boston, MA 02111-1307, USA.
18: */
19:
20: package ca.mcgill.sable.soot.attributes;
21:
22: import java.io.*;
23:
24: public class AttributeFileReader {
25:
26: private String filename;
27:
28: /**
29: * Method AttributeFileReader.
30: * @param filename
31: */
32: public AttributeFileReader(String filename) {
33: setFilename(filename);
34: }
35:
36: /**
37: * Method readFile.
38: * @return String
39: * reads given file trimming white space
40: */
41: public String readFile() {
42: StringBuffer file = new StringBuffer();
43: try {
44: BufferedReader br = new BufferedReader(new FileReader(
45: getFilename()));
46: while (true) {
47: String temp = br.readLine();
48: if (temp == null)
49: break;
50: temp = temp.trim();
51: file.append(temp);
52:
53: }
54:
55: } catch (IOException e1) {
56: System.out.println(e1.getMessage());
57: }
58: return file.toString();
59:
60: }
61:
62: /**
63: * Returns the filename.
64: * @return String
65: */
66: public String getFilename() {
67: return filename;
68: }
69:
70: /**
71: * Sets the filename.
72: * @param filename The filename to set
73: */
74: public void setFilename(String filename) {
75: this.filename = filename;
76: }
77:
78: }
|