venkata raidu wrote:
> Hi Mark,
> Thanks for the reply. I have gone through the web page which you
> forwarded.
> It seems like, the article is related to file output on to a
> desktop.
Java I/O is Java I/O, by and large.
> But, I need something specific to Android, where I can print my
> data onto a temporary file on android.
That's fine, but 90% of what you need to do for that is tied to Java
I/O, not to Android.
Also, your original post suggested that you had not tried anything,
since you did not ask any concrete questions about specific techniques.
> I was trying the following code:
>
> public class Packager extends Activity {
> /** Called when the activity is first created. */
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
> FileOutputStream foStream;
> PrintStream pStream;
>
> try {
> foStream =
> getBaseContext().openFileOutput("myfile.txt", 0);
> pStream = new PrintStream(foStream);
> pStream.print("This content has been printed");
>
> } catch (FileNotFoundException e) {
> // TODO Auto-generated catch block
>
> }
> }
> }
>
> Please let me know if anything is wrong in the above code.
You should log your exceptions. I would skip the 2nd parameter on
openFileOutput(). This doesn't seem to have anything to do with byte
arrays and PNG files. You do not need getBaseContext() -- an Activity is
a Context, so you can just call openFileOutput().
Otherwise, it seems fine.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
Android Training...At Your Office: http://commonsware.com/training
--
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