all groups > vj# > december 2004 >
You're in the

vj#

group:

Create a file from a binary stream



Create a file from a binary stream raffaele
12/20/2004 9:31:02 AM
vj#: I have stored a binary stream of a file in the db. When I take this value and
I put it in a Object, then how can I create the file to stored it on the
hard disk?
Re: Create a file from a binary stream Lars-Inge Tønnessen [VJ# MVP]
12/27/2004 7:44:10 PM

Please try a binary serializable formater.

Somthing like this:

/** @attribute System.SerializableAttribute() */
public class test implements java.io.Serializable
{
public int number = 0;
}

public class Class1
{
public Class1()
{
try
{
test one = new test();
one.number = 10;

System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formater =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

System.IO.Stream YourStream = new System.IO.FileStream( "path.bin",
System.IO.FileMode.Create,
System.IO.FileAccess.Write,
System.IO.FileShare.None);

formater.Serialize( YourStream, one );
}
catch ( Exception e )
{
System.Console.WriteLine( e.getMessage() );
}

}

/** @attribute System.STAThread() */
public static void main(String[] args)
{
new Class1();
}
}



Regards,
Lars-Inge Tønnessen

AddThis Social Bookmark Button