Changeset 17553 for other-projects/trunk
- Timestamp:
- 2008-10-17T14:24:07+13:00 (16 years ago)
- Location:
- other-projects/trunk/anttasks
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/trunk/anttasks/build.xml
r17350 r17553 49 49 <target name="test-rsr" depends="test-setup"> 50 50 51 <echo file="test/rsr1.txt">This is a test of the rsr task 52 To see if it can replace things with other things 53 Or if those things 54 Stay the same things 55 56 Or not 57 58 Replace with a path 59 @path@ 60 61 Replace with a path, with winPath on 62 @path-with-winpath@ 63 64 65 </echo> 66 <copy file="test/rsr1.txt" tofile="test/rsr2.txt"/> 67 <copy file="test/rsr1.txt" tofile="test/rsr3.txt"/> 68 <copy file="test/rsr1.txt" tofile="test/rsr4.txt"/> 51 <copy file="src/test/rsr.txt" tofile="test/rsr1.txt"/> 52 <copy file="src/test/rsr.txt" tofile="test/rsr2.txt"/> 53 <copy file="src/test/rsr.txt" tofile="test/rsr3.txt"/> 54 <copy file="src/test/rsr.txt" tofile="test/rsr4.txt"/> 69 55 70 56 <rsr file="test/rsr1.txt" pattern="things" replacement="strings"/> -
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.