Re:parsing txt file - seems unparsable
Thanks! will let you know how it goes. I have really been seeing the usefulness of using Java with CF lately. ~~ Stephenie I reckon you'll be needing a Java CFX then. Seemed like a fun 5 minute project so here ya go. - import com.allaire.cfx.*; import java.io.*; public class cfReadTxtFile implements CustomTag{ public void processRequest( Request request, Response response ) throws Exception { if ( !request.attributeExists(filename) || !request.attributeExists(variable) ) { throw new Exception(Missing attributes, filename and variable are required.); } String filename = request.getAttribute( filename ); String variable = request.getAttribute( variable ); String fileContent = ; try { BufferedReader in = new BufferedReader(new FileReader(filename)); String str; while ((str = in.readLine()) != null) { fileContent = fileContent + str + System.getProperty(line.separator); } in.close(); } catch (IOException e) { } response.setVariable( variable, fileContent); } } --- Call it like so... cfx_cfReadTxtFile filename=d:\sites\test\string.cfm variable=test cfdump var=#test# Tested and works perfectly on CF5 I'll mail you the source and the compiled CFX off list aswell. Craig. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re:parsing txt file - seems unparsable
Tried this on CF5, and received this error: Unhandled System exception ! Failed to create JavaVM. JNI_CreateJavaVM returned error code JNI_ERR (this may indicate an unrecognized option string) which comes from line: cfobject type=JAVA name=jFR class=java.io.FileReader action=""> any ideas? BTW, using cffile in CFMX to read the file works great, it doesn't choke on the null char. Too bad we don't have MX yet on our corporate servers (sigh). ~~ Stephenie This is better though. cfobject type=JAVA name=jFR class=java.io.FileReader action=""> cfset jFRobj = jFR.init('d:/sites/test/dates.cfm') cfobject type=JAVA name=jBR class=java.io.BufferedReader action=""> cfset jBRobj = jBR.init(jFRobj) pre cfscript line = ; while ( isDefined(line) ){ line = jBRobj.readLine(); if ( isDefined(line) ){ writeoutput(line #chr(13)#); } } jBRobj.close(); /cfscript /pre Seems as soon as we reach EOF, jBRobj.readLine() returns null (expected) and variable 'line' is no longer defined, quite handy in this case. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re:parsing txt file - seems unparsable
yes it is cf 5. i suspect you may be right. will try some tweaking as soon as i kick this flu. thanks! steph [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re:parsing txt file - seems unparsable
nice idea, but no love. thanks! Stephenie If you're still having trouble, instead of CFFILE, try this cfsavecontent variable=myDoc. cfinclude template=myDoc.txt /cfsavecontent Now parse your file. H. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re:parsing txt file - seems unparsable
it does not display the whole file. it stops when it gets to the little square on the first line. i can't even get to the part of inserting into db because i get only part of the first line. sigh Stephenie if you output the content of the file in your cf template (prior to db insert) does it display the whole thing? If so, are you using cfqueryparam? [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re:parsing txt file - seems unparsable
If i open the file in notepad, then save it (without making any changes) it works fine. h...wonder how/if i can use cfexecute to have notepad open the file and then save it? other than that, i can't think of anything else... Steph [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re:parsing txt file - seems unparsable
This sounds line an end -f line or carriage return character (or both) Do a replace of each [chr(10) chr(13); replace with white space or some marker for your illumination ~~~ or whatever ] in the variable and see if that helps. Are you SURE it's not in the database, as well? Just kicked down a line? If i open the file in notepad, then save it (without making any changes) it works fine. h...wonder how/if i can use cfexecute to have notepad open the file and then save it? other than that, i can't think of anything else... Steph [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re:parsing txt file - seems unparsable
Is this CF 5 or earlier? If so, it is probably actually a NULL chr(0) character. Notepad will get rid of it when you open and save the file. CF 5 and earlier have trouble with strings containing NULLs, since it uses NULLs to mark the end of strings (I think). The data is still in the string, but all of the output string functions stop at that character. Solution? I don't have one. This is where Java and Custom Tags come in handy. Jerry Johnson [EMAIL PROTECTED] 10/01/03 02:08PM This sounds line an end -f line or carriage return character (or both) Do a replace of each [chr(10) chr(13); replace with white space or some marker for your illumination ~~~ or whatever ] in the variable and see if that helps. Are you SURE it's not in the database, as well? Just kicked down a line? If i open the file in notepad, then save it (without making any changes) it works fine. h...wonder how/if i can use cfexecute to have notepad open the file and then save it? other than that, i can't think of anything else... Steph [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]