-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Fri, 6 Sep 2002, at 10:54:37 [GMT -0700], Martin Naskovski wrote:
MN> Hi all, I'm wondering if there's some script (which I really am a bit MN> short on time at work here to write) that someone has written that MN> could take the UNIX % delimited fortune lines(cookies) and transform MN> them into cookies that are acceptable to TB! ? If anyone knows about MN> such a script, could you forward it to me or point me in the direction MN> where it lives? This is something I wrote while playing with JAVA. package sigcopy; import java.io.*; import java.util.*; /** * Title: SigCopy * Description: Copy from a multi-line style to a one-line style .sig file. * Copyright: Copyright (c) 2002 * Company: * @author Michael A. Yetto * @version 1.0 */ public class SigCopy { public static void main(String[] args) { try { String dirS = "D:\\The Bat!\\MAIL\\<account>\\"; String singleFile = "<single line filename>"; String dirML = "D:\\Tools\\KookieJar6\\taglines\\"; String mlFile = "<multi-line filename>"; boolean EOF = false; File fileIn = new File(dirML, mlFile); File fileOut = new File(dirS,singleFile); MLSigIn sigIn = new MLSigIn(fileIn); SingleSigOut sigOut = new SingleSigOut(fileOut); while (!EOF) { try { sigOut.write(sigIn.readLine()); } catch(EOFException e) { EOF = true; break; } catch(NullPointerException np) { EOF = true; break; } } sigOut.close(); sigIn.close(); } catch(FileNotFoundException e) { System.err.println(e); return; } catch(IOException e) { System.err.println("Error reading input file" + e ); return; } } } Part 2 package sigcopy; import java.io.*; import java.util.*; public class SingleSigOut { static BufferedWriter sSig; static String sep = "\\n"; public SingleSigOut(File f) throws IOException { sSig = new BufferedWriter(new FileWriter(f)); } public SingleSigOut(File f, String s) throws IOException { sSig = new BufferedWriter(new FileWriter(f)); sep = s; } public static void write(Vector v) throws IOException { String s = new String(); s = ((String) v.elementAt(0)); for (int j=1;j<v.size()-1;j++) { s = s + sep; s = s + ((String) v.elementAt(j)); } sSig.write(s); sSig.newLine(); sSig.flush(); } public static void close() throws IOException { sSig.flush(); sSig.close(); } } And finally package sigcopy; import java.io.*; import java.util.*; public class MLSigIn { static BufferedReader mlSig; static String sep = "%"; public MLSigIn(File f) throws IOException { mlSig = new BufferedReader(new FileReader(f)); } public MLSigIn(File f, String s) throws IOException { mlSig = new BufferedReader(new FileReader(f)); sep = s; } public static Vector readLine() throws IOException { String st = new String(); Vector v = new Vector(); while (! st.equals(sep)) { st=mlSig.readLine(); v.addElement(st); } v.trimToSize(); return v; } public static void close() throws IOException { mlSig.close(); } } I will probably tweak this when I'm so inclined, but for now enter the appropriate paths and filenames to convert a multi-line file delimited with "%", to a single line file with a "\n" line separator. Mike Yetto - -- E-mailed using The Bat! v1.61 running on Windows 2000 5.0 Build 2195 Service Pack 2 -----BEGIN PGP SIGNATURE----- Version: PGP 6.5.8 iQA/AwUBPXkixNkz/SR3Uv4yEQJb/QCg/RdVmMurodsfHGoOTg5cpQbGF3QAn27N 9v3xjp4Ugvas3sX4+JY6yEQ6 =6SP5 -----END PGP SIGNATURE----- ________________________________________________ Current version is 1.61 | "Using TBUDL" information: http://www.silverstones.com/thebat/TBUDLInfo.html