java.lang.Object | +--crlf
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
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.
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 |
public crlf(java.io.File dir, java.lang.String sTemplate, boolean bFiles, boolean bDirs)
Method Detail |
public boolean accept(java.io.File dir, java.lang.String sFileName)
public boolean matchWildCard(java.lang.String sFullString, java.lang.String sPartialExp)
public static void main(java.lang.String[] args)
args
- Array of file names to scan.public static void processFile(java.lang.String sFileName, java.lang.String sFileTemplate, java.lang.String sLineSep, boolean bRecurse, boolean bFirstLevel)
public static void convertFile(java.lang.String sFileName, java.lang.String sLineSep)