litesoft
@ 958
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
package org.litesoft.util; import org.litesoft.commonfoundation.base.*; import org.litesoft.commonfoundation.typeutils.*; import org.litesoft.server.file.*; import org.litesoft.server.util.*; import java.io.*; public class JavaNewLineNormalizer implements DirectoriesDepthFirst.Visitor { public static void main( String[] args ) throws Exception { new DirectoriesDepthFirst( new JavaNewLineNormalizer( FileUtils.createFileNameFilter( "", ".java" ) ) ) .process( new File( Directories.currentWorking() ) ); } private FilenameFilter mFileNameFilter; private JavaNewLineNormalizer( FilenameFilter pFileNameFilter ) { mFileNameFilter = pFileNameFilter; } @Override public void process( File pDirectory ) throws IOException { String[] zFileNames = pDirectory.list( mFileNameFilter ); if ( Currently.isNotNullOrEmpty( zFileNames ) ) { System.out.println( " " + pDirectory + ":" ); for ( String zFileName : zFileNames ) { process( pDirectory, zFileName ); } } } private void process( File pDirectory, String pFileName ) throws UnsupportedEncodingException { System.out.print( " " + pFileName ); File zFile = new File( pDirectory, pFileName ); byte[] zBytes = FileUtils.loadTextFileAsString( zFile ).getBytes( IOUtils.UTF_8 ); FileUtils.Change zChange = FileUtils.storeFile( zFile, Lists.of( zBytes ) ); System.out.println( (zChange == null) ? "" : (" ---------------> " + zChange) ); } } |