Reading http request as IO in rails

Here's what i'm trying to do my mobile phone app ( j2me) tries to
connect to the my rails application.
the j2me app opens a here's the snippet
               hc = (HttpConnection),
               hc.setRequestProperty("If-Modified-Since", "29 Oct
19:43:31 GMT");
               hc.setRequestProperty("User-Agent", "Profile/MIDP-2.0
               hc.setRequestProperty("Content-Language", "en-US");
               out = hc.openOutputStream();

j2me app then just writes data to the output stream(pretty basic
here). so far so good. not a problem here.
And on my rails controller i do the following,

class MainController < ApplicationController
def read_data
   url = request.env["REQUEST_URI"]
   method = request.env["REQUEST_METHOD"]
   data = request.env["RAW_POST_DATA"]

   newf ="MY_DATA", "wb")
   str =
   render :text => "Hello Load #{url}"

the problem is the same j2me app works(only changes the url) if i have
a servlet receiving the data, i do request.getInputStream on a servlet
and everything works.
But on rails i get ioexception under j2me app saying couldn't write to

Also is the correct way to do it. ?
Is this possible in rails or am i making the wrong assumptions here ?
what am i doing wrong, or rather how is it done.

I appreciate any insights that you may have.

So i should take it that this is not possible in rails ?