KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > attributes > AttributeFileReader


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * 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
25 public class AttributeFileReader {
26
27     private String JavaDoc filename;
28     
29     /**
30      * Method AttributeFileReader.
31      * @param filename
32      */

33     public AttributeFileReader(String JavaDoc filename) {
34         setFilename(filename);
35     }
36     
37     /**
38      * Method readFile.
39      * @return String
40      * reads given file trimming white space
41      */

42     public String JavaDoc readFile() {
43         StringBuffer JavaDoc file = new StringBuffer JavaDoc();
44         try {
45             BufferedReader br = new BufferedReader( new
46                     FileReader(getFilename()));
47             while (true) {
48                 String JavaDoc temp = br.readLine();
49                 if (temp == null) break;
50                 temp = temp.trim();
51                 file.append(temp);
52                             
53             }
54             
55         }
56         catch (IOException e1) {
57             System.out.println(e1.getMessage());
58         }
59         return file.toString();
60             
61     }
62     
63     /**
64      * Returns the filename.
65      * @return String
66      */

67     public String JavaDoc getFilename() {
68         return filename;
69     }
70
71     /**
72      * Sets the filename.
73      * @param filename The filename to set
74      */

75     public void setFilename(String JavaDoc filename) {
76         this.filename = filename;
77     }
78
79 }
80
Popular Tags