See the attached file.. Do with it what you want :) Mvgr, Martin
On Wed, 2004-02-04 at 09:24, Antoine Lévy-Lambert wrote: > Martin van den Bemt wrote: > > >I have a little tool to get that handled.. Let me know if you need it.. > >(pretty basic java file..) > > > >Mvgr, > >Martin > > > >On Wed, 2004-02-04 at 00:33, Antoine Lévy-Lambert wrote: > > > > > >>Ooops. > >>The lines 2 and 15 in all the java files after the update contain a > >>trailing space after the * which checkstyle counts as an error. > >>:-( > >>Do we want to repair this ? > >>Antoine > >> > >>[EMAIL PROTECTED] wrote: > >> > >> > >> > Yes, I am interested to get this file. > > Thanks > > Antoine > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Mvgr, Martin
package com.mvdb.tools.checkstyle; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; /** * Removes whitespaces at the end of a line. * * @author <a href="mailto:[EMAIL PROTECTED]">Martin van den Bemt</a> * @version $Id: RemoveWhiteSpace.java,v 1.1 2004/01/06 19:12:32 mvdb Exp $ */ public class RemoveWhiteSpace { File file; /** * */ public RemoveWhiteSpace() { super(); } public RemoveWhiteSpace(String dirFile) throws FileNotFoundException { this.file = new File(dirFile); if (!file.exists()) { throw new FileNotFoundException("File or Directory : "+dirFile+" not found"); } } public void process() { if (file.isDirectory()) { String[] files = file.list(); String ap = file.getAbsolutePath(); if (!ap.endsWith(File.separator)) { ap+=File.separator; } System.out.println("ap : "+ap); for (int i = 0; i < files.length; i++) { //System.out.println("app : "+ap+files[i]); File f = new File(ap+files[i]); if (!f.isDirectory() && files[i].endsWith(".java")) { System.out.println("f : "+f); removeSpaces(f); } } } else { removeSpaces(this.file); } } protected void removeSpaces(File javaFile) { BufferedReader in = null; BufferedOutputStream out = null; try { System.out.println("javafile : "+javaFile.getAbsolutePath()); in = new BufferedReader(new FileReader(javaFile)); out = new BufferedOutputStream(new FileOutputStream(javaFile.getAbsolutePath()+".tmp")); String line = null; while ((line = in.readLine())!=null) { while (line.endsWith(" ")) { System.out.println(line+"..."); System.out.println("Line length b : "+line.length()); line = line.substring(0,line.length()-1); System.out.println("Line length a : "+line.length()); System.out.println(line+"..."); } line+="\r\n"; out.write(line.getBytes()); } }catch(Exception e) { e.printStackTrace(); }finally { try { in.close(); }catch(Exception e) { e.printStackTrace(); } try { out.flush(); out.close(); }catch(Exception e) { e.printStackTrace(); } } try { javaFile.delete(); File newFile = new File(javaFile.getAbsolutePath()+".tmp"); newFile.renameTo(javaFile); }catch(Exception e) { e.printStackTrace(); } } public static void main(String[] args) throws Exception { String home = "C:/martin/eclipse/nyx.xulux.org/src/java/org/xulux/nyx/"; args = new String[] { home+"swing/widgets/handlers" }; if (args == null || args.length == 0) { showUsage(); return; } RemoveWhiteSpace rmws = new RemoveWhiteSpace(args[0]); rmws.process(); } public static void showUsage() { } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
