As suspected it was straight-forward using java. I've wrapped the java
stuff in a "binaryFileWriter" component but here is the jist of what
it does:
<cfscript>
variables.path = ExpandPath("myFile.dat");
variables.fileOut = CreateObject("java",
"java.io.FileOutputStream").init( path );
variables.out = CreateObject("java",
"java.io.DataOutputStream").init( fileOut );
out.writeInt( JavaCast('int', 453) );
out.writeFloat( JavaCast('float', 349587.345) );
out.writeLong( JavaCast('long', 349584647345) );
out.writeUTF( "Hello world" );
out.writeChar('H');
// etc
out.close();
</cfscript>
Using the component I wrote could look something like:
<cfscript>
variables.out = CreateObject("component", "binaryFileWriter").init(
"myFile.dat" );
out.writeInt( 453 );
out.writeFloat( 349587.345 );
out.writeLong( 349584647345 );
out.writeUTF( "Hello world" );
out.writeChar('H');
// etc
out.close();
</cfscript>
Not a huge difference but hides all the java references and stops the
need for using Javacast in all the code. I'm guessing there should be
two components here that wrap both the dataOutputStream and
fileOutputStream - so you could build a binary data stream without
writing to file. But anyways, boring myself now - time for bed.
Dominic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:316213
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4