Changeset 17553 for other-projects/trunk/anttasks/src/org
- Timestamp:
- 2008-10-17T14:24:07+13:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/trunk/anttasks/src/org/greenstone/anttasks/RegexSearchReplace.java
r17349 r17553 53 53 } 54 54 55 if ( !file.exists() ) { 56 throw new BuildException( "Error - File not found !!" ); 57 } 58 55 59 if ( jobs == null && pattern == null ) { 56 60 throw new BuildException( "Error - No pattern attribute and no nested jobs !!" ); … … 98 102 99 103 //writer to temp file 100 out = new BufferedWriter( new FileWriter(temp));104 out = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(temp), "UTF8") ); 101 105 102 106 } catch (IOException e) { … … 108 112 BufferedReader in = null; 109 113 try { 110 in = new BufferedReader( new FileReader( file) );114 in = new BufferedReader( new InputStreamReader(new FileInputStream(file), "UTF8") ); 111 115 } catch ( Exception e ) { 112 116 throw new BuildException( "Error - Couldn't open the specified file" ); … … 114 118 115 119 //pass the file through, searching and replacing 116 String line ;120 String line = null; 117 121 boolean hasMoreLines = true; 118 122 while ( hasMoreLines ) { … … 121 125 line = in.readLine(); 122 126 } catch ( Exception e ) { 127 System.err.println( e.getMessage() ); 123 128 throw new BuildException( "Error - Couldn't read from the specified file" ); 124 129 } … … 150 155 151 156 try { 152 out.write( line);157 out.write( line ); 153 158 out.newLine(); 154 159 } catch ( Exception e ) { … … 157 162 } 158 163 } 159 160 164 161 165 try { 162 166 //close them both up
Note:
See TracChangeset
for help on using the changeset viewer.