why not use fos.write(buffer) as your "standard java platform" example does?

you don't want to use Writers here, because 
you're dealing with binary data. i think you 
might be confused by your corresponding read(), 
where you presumably (and properly) use Writers 
to write the encoded Base64 strings.

also, close your streams in a finally block. that 
way they'll be closed if something inside the try 
block throws. otherwise you'll leave file 
descriptors hanging.

hth



>does anyone have an idea? I want to set byte[] as argument..
>
>On 10åé13ì™, åþå“11:58, dai <[EMAIL PROTECTED]> wrote:
>>  Hi, could you anybody know how to save data using FileoutputStream
>>  like below with byte[] argument?
>>  Upon standard java platform, I could save data as zip using
>>  FileOutputStream with byte[] argument however on Android platform, the
>>  method does not have wirte(byte[]) but it does have write(byte[]).
>>
>>  Is thie meaning that I can only chante byte[] to String looking around
>>  web pages? Or is there anything that I have to consider because of
>>  android specific manners like this..??
>>
>>  // Android Platform
>>          public void write(Context context, String data){
>>                  byte[] outdata = Base64.decode(data);
>>                  FileOutputStream fos = null;
>>                  BufferedWriter out = null;
>>                  try {
>>                          fos = context.openFileOutput("output.zip", 0);
>>                          out = new 
>>BufferedWriter(new OutputStreamWriter(fos));
>>                          out.write( ????? );
>>                          out.flush();
>>                          out.close();
>>                          fos.close();
>>                 } catch(....
>>
>>  // Standard Java Platform
>>          public void write(String data){
>>                 try {
>>                          byte[] outdata = 
>>Base64.decodeBase64(data.getBytes());
>>
>>                          File of = new File("output.zip");
>>                          FileOutputStream osf = new FileOutputStream(of);
>>                          osf.write(outdata);
>>                          osf.flush();
>>                 } catch ....
>>
>>  Thank you so much
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to