From: Rajesh Olafson Date: 2008-06-12T11:08:41+09:00 Subject: Re: write byte array to file ------=_Part_33128_20075074.1213236537922 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello Tim, I do like file_name=new_foo.gif # myMethod return a byte array for file_name my_byte_array = myMethod('foo.gif') puts my_byte_array.class # => Array outfile = File.new('new_foo.gif', 'w') outfile.puts(byteArray) outfile.close ---- now outfile only had some nonsense text. # file new_foo.gif ascii text ? Thank you. Rajesh. On Wed, Jun 11, 2008 at 6:34 PM, Tim Hunter wrote: > Rajesh Olafson wrote: > >> I have method that read a binary file - maybe a image, and return a byte >>>> array. >>>> >>>> I want write the byte array to another file. But I keep writing the >>>> bytes >>>> as >>>> text. I want binary. >>>> >>>> What need I do? >>>> >>>> Rajesh. >>>> >>>> >>>> I'm guessing that you're on Windows. Open the file with the 'b' flag, >>> i.e. >>> 'wb'. >>> >>> >> Thank you. >> no. I use linux ubuntu. shold have said that before. >> >> With my file write I just get text in the file. Not binary. >> ? >> >> > Then I don't understand. What do you mean you "just get text"? If you're on > Linux or you've opened the file with the b flag, then you should get the > data you write w/o conversion. > > Maybe it would help if you showed an example of your code. > > > -- > RMagick: http://rmagick.rubyforge.org/ > RMagick 2: http://rmagick.rubyforge.org/rmagick2.html > > ------=_Part_33128_20075074.1213236537922--