Buggy code:
public class ReplaceRegExp extends Task { private File file ; private String flags ; private boolean byline ; private Vector filesets ; private RegularExpression regex ; private Substitution subs ; private FileUtils fileUtils = FileUtils . newFileUtils ( ) ; private String encoding = null ; public ReplaceRegExp ( ) { } public void setFile ( File file ) { } public void setMatch ( String match ) { } public void setReplace ( String replace ) { } public void setFlags ( String flags ) { } public void setByLine ( String byline ) { } public void setByLine ( boolean byline ) { } public void setEncoding ( String encoding ) { } public void addFileset ( FileSet set ) { } public RegularExpression createRegexp ( ) { } public Substitution createSubstitution ( ) { } protected String doReplace ( RegularExpression r , Substitution s , String input , int options ) { } protected void doReplace ( File f , int options ) throws IOException { File temp = fileUtils . createTempFile ( "replace" , ".txt" , null ) ; temp . deleteOnExit ( ) ; Reader r = null ; Writer w = null ; try { if ( ( encoding ) == null ) { r = new FileReader ( f ) ; w = new FileWriter ( temp ) ; } else { r = new InputStreamReader ( new FileInputStream ( f ) , encoding ) ; w = new OutputStreamWriter ( new FileOutputStream ( temp ) , encoding ) ; } BufferedReader br = new BufferedReader ( r ) ; BufferedWriter bw = new BufferedWriter ( w ) ; PrintWriter pw = new PrintWriter ( bw ) ; boolean changes = false ; log ( ( ( ( ( ( ( ( ( ( "Replacing<seq2seq4repair_space>pattern<seq2seq4repair_space>'" + ( regex . getPattern ( getProject ( ) ) ) ) + "'<seq2seq4repair_space>with<seq2seq4repair_space>'" ) + ( subs . getExpression ( getProject ( ) ) ) ) + "'<seq2seq4repair_space>in<seq2seq4repair_space>'" ) + ( f . getPath ( ) ) ) + "'" ) + ( byline ? "<seq2seq4repair_space>by<seq2seq4repair_space>line" : "" ) ) + ( ( flags . length ( ) ) > 0 ? ( "<seq2seq4repair_space>with<seq2seq4repair_space>flags:<seq2seq4repair_space>'" + ( flags ) ) + "'" : "" ) ) + "." ) , MSG_VERBOSE ) ; if ( byline ) { StringBuffer linebuf = new StringBuffer ( ) ; String line = null ; String res = null ; int c ; boolean hasCR = false ; do { c = br . read ( ) ; if ( c == '\r' ) { if ( hasCR ) { line = linebuf . toString ( ) ; res = doReplace ( regex , subs , line , options ) ; if ( ! ( res . equals ( line ) ) ) { changes = true ; } pw . print ( res ) ; pw . print ( '\r' ) ; linebuf = new StringBuffer ( ) ; } else { hasCR = true ; } } else if ( c == '\n' ) { line = linebuf . toString ( ) ; res = doReplace ( regex , subs , line , options ) ; if ( ! ( res . equals ( line ) ) ) { changes = true ; } pw . print ( res ) ; if ( hasCR ) { pw . print ( '\r' ) ; hasCR = false ; } pw . print ( '\n' ) ; linebuf = new StringBuffer ( ) ; } else { if ( hasCR || ( c < 0 ) ) { line = linebuf . toString ( ) ; res = doReplace ( regex , subs , line , options ) ; if ( ! ( res . equals ( line ) ) ) { changes = true ; } pw . print ( res ) ; if ( hasCR ) { pw . print ( '\r' ) ; hasCR = false ; } linebuf = new StringBuffer ( ) ; } if ( c >= 0 ) { linebuf . append ( ( ( char ) ( c ) ) ) ; } } } while ( c >= 0 ) ; pw . flush ( ) ; } else { <START_BUG> String buf = fileUtils . readFully ( br ) ; <END_BUG> if ( buf == null ) { buf = "" ; } String res = doReplace ( regex , subs , buf , options ) ; if ( ! ( res . equals ( buf ) ) ) { changes = true ; } pw . print ( res ) ; pw . flush ( ) ; } r . close ( ) ; r = null ; w . close ( ) ; w = null ; if ( changes ) { log ( "File<seq2seq4repair_space>has<seq2seq4repair_space>changed;<seq2seq4repair_space>saving<seq2seq4repair_space>the<seq2seq4repair_space>updated<seq2seq4repair_space>file" , MSG_VERBOSE ) ; try { fileUtils . rename ( temp , f ) ; temp = null ; } catch ( IOException e ) { throw new BuildException ( ( "Couldn't<seq2seq4repair_space>rename<seq2seq4repair_space>temporary<seq2seq4repair_space>file<seq2seq4repair_space>" + temp ) , getLocation ( ) ) ; } } else { log ( "No<seq2seq4repair_space>change<seq2seq4repair_space>made" , MSG_DEBUG ) ; } } finally { try { if ( r != null ) { r . close ( ) ; } } catch ( Exception e ) { } try { if ( w != null ) { w . close ( ) ; } } catch ( Exception e ) { } if ( temp != null ) { temp . delete ( ) ; } } } public void execute ( ) throws BuildException { } }

Fix:
String buf = FileUtils . readFully ( br ) ;