Class crlf

java.lang.Object
  |
  +--crlf

public class crlf
extends java.lang.Object
implements java.io.FilenameFilter

How many times have you transferred files from a UNIX machine to Windows or vice versa and then discovered that you did a binary transfer by mistake? What do you do then? You can ftp them again! What about downloaded files? I can give you one example - JDK sources from Sun. They always come with UNIX style line feeds only. Viewing them with notepad becomes a pain. So here's an utility to make life simpler. Just run this utility against your file and bingo! all those black boxes and ^M are gone.

Usage:
java crlf [-template template] [-recurse] file1 file2 ...
template can be a simple wild card with '*' and '?'
recurse option enables resursing sub-directories
filename can be name of a file or a directory

You are free to use this code and to make modifications provided this notice is retained.

If you found this useful, please add a note of acknowledgement to my guestbook. If you would like to report a bug or suggest some improvements, you are most welcome. I will be happy to help you use this piece of code.

Version:
1.00, 7th Jan, 1999
Author:
Tanmay K. Mohapatra

Constructor Summary
crlf(java.io.File dir, java.lang.String sTemplate, boolean bFiles, boolean bDirs)
          The same class acts as a FilenameFilter.
 
Method Summary
 boolean accept(java.io.File dir, java.lang.String sFileName)
          Accept returns true if the file passes the filter.
static void convertFile(java.lang.String sFileName, java.lang.String sLineSep)
          Convert all line separators in this file.
static void main(java.lang.String[] args)
           
 boolean matchWildCard(java.lang.String sFullString, java.lang.String sPartialExp)
          Function matches simple wild cards containing '?' or '*'
static void processFile(java.lang.String sFileName, java.lang.String sFileTemplate, java.lang.String sLineSep, boolean bRecurse, boolean bFirstLevel)
          process this file or if it is a directory then process the files within that.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

crlf

public crlf(java.io.File dir,
            java.lang.String sTemplate,
            boolean bFiles,
            boolean bDirs)
The same class acts as a FilenameFilter. This is the constructor for that.
Method Detail

accept

public boolean accept(java.io.File dir,
                      java.lang.String sFileName)
Accept returns true if the file passes the filter.
Specified by:
accept in interface java.io.FilenameFilter

matchWildCard

public boolean matchWildCard(java.lang.String sFullString,
                             java.lang.String sPartialExp)
Function matches simple wild cards containing '?' or '*'

main

public static void main(java.lang.String[] args)
Parameters:
args - Array of file names to scan.

processFile

public static void processFile(java.lang.String sFileName,
                               java.lang.String sFileTemplate,
                               java.lang.String sLineSep,
                               boolean bRecurse,
                               boolean bFirstLevel)
process this file or if it is a directory then process the files within that.

convertFile

public static void convertFile(java.lang.String sFileName,
                               java.lang.String sLineSep)
Convert all line separators in this file.