Ignore:
Timestamp:
2008-10-17T14:24:07+13:00 (16 years ago)
Author:
oranfry
Message:

changes to make rsr properly handle UTF-8

Location:
other-projects/trunk/anttasks/src
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/trunk/anttasks/src/org/greenstone/anttasks/RegexSearchReplace.java

    r17349 r17553  
    5353        }
    5454
     55        if ( !file.exists() ) {
     56            throw new BuildException( "Error - File not found !!" );
     57        }
     58
    5559        if ( jobs == null && pattern == null ) {
    5660            throw new BuildException( "Error - No pattern attribute and no nested jobs !!" );
     
    98102
    99103            //writer to temp file
    100             out = new BufferedWriter(new FileWriter(temp));
     104            out = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(temp), "UTF8") );
    101105
    102106        } catch (IOException e) {
     
    108112        BufferedReader in = null;
    109113        try {
    110             in = new BufferedReader( new FileReader( file ) );
     114            in = new BufferedReader( new InputStreamReader(new FileInputStream(file), "UTF8") );
    111115        } catch ( Exception e ) {
    112116            throw new BuildException( "Error - Couldn't open the specified file" );
     
    114118
    115119        //pass the file through, searching and replacing
    116         String line;
     120        String line = null;
    117121        boolean hasMoreLines = true;
    118122        while ( hasMoreLines ) {
     
    121125                line = in.readLine();
    122126            } catch ( Exception e ) {
     127                System.err.println( e.getMessage() );
    123128                throw new BuildException( "Error - Couldn't read from the specified file" );
    124129            }
     
    150155
    151156                try {
    152                     out.write(line);
     157                    out.write( line );
    153158                    out.newLine();
    154159                } catch ( Exception e ) {
     
    157162            }
    158163        }
    159            
    160 
     164       
    161165        try {
    162166            //close them both up
Note: See TracChangeset for help on using the changeset viewer.