/* * [H3Patch.java] * * Summary: One shot to prepare Patch Script to change some

. * @since 2014-04-28 */ public class H3Patch { /** * read file * file: filenem * from string * from string * and create a CSVRecode file * * @param args not used * * @throws java.io.IOException if cannot read or write source files. */ public static void main( final String[] args ) throws IOException { int countFiles = 0; int countPatches = 0; int countJunk = 0; int countCorrupted = 0; String filename = "unknown"; String line = null; // O P E N final FileReader fr = new FileReader( "C:/temp/corrections.txt" ); final BufferedReader br = new BufferedReader( fr, 24 * 1024 ); CSVWriter w = new CSVWriter( EIO.getPrintWriter( new File( "C:/temp/patch.csv" ), 32 * 1024, EIO.UTF8 ), -1, ',', '\"', '#', true ); while ( ( line = br.readLine() ) != null ) { // we atteche filename to each of folling patch lines. // R E A D if ( line.startsWith( "file : " ) ) { filename = ST.chopLeadingString( line, "file : " ); countFiles++; } else if ( line.startsWith( "

" ) && line.endsWith( "

" ) ) { final String to = line; // we read what we want. We deduce what it used to be. final String from = "

" + ST.chopTrailingString( ST.chopLeadingString( line, "

" ), "

" ) + ""; w.put( from, to, filename ); w.nl(); countPatches++; } else { if ( line.contains( "h3" ) ) { countCorrupted++; out.println( "corrupted ignored in file: " + filename + " : " + line ); } else { countJunk++; out.println( " junk ignored in file: " + filename + " : " + line ); } } } // end loop // C L O S E br.close(); w.close(); out.println( countFiles + " files " + countPatches + " patches " + countCorrupted + " corrupted " + countJunk + " junk" ); } }