I would avoid using the PrintWriter class since it doesn't throw
exceptions. You would need to call checkError() after each operation,
and you would then only get a return value that says that an error has
occured or not. You won't be able to find out why it failed, and won't
see any error messages.

Use a DataOutputStream(new FileOutputStream()) if you want to have a
"binary" file, and e.g. a BufferedWriter(new FileWriter()) if you want
to have a text file.


On 29 Juli, 15:14, Lorenz <[email protected]> wrote:
> At the end I've found the way to write  a file:
>
> Use PrintWriter: openOutputFile(String:name file) to create or open an
> existent file.
> PrintWriter f=new PrintWriter(openOutputFile(String:name file));
> f.println("something) ; to write on the file.
> Thanks Micheal!
>
> On Jul 29, 2:00 pm, Michael Leung <[email protected]> wrote:
>
>
>
> > I found a thread about writing files.
>
> >http://www.anddev.org/working_with_files-t115-s30.html
>
> > Would it be helpfule for you?
>
> > On Wed, Jul 29, 2009 at 2:59 AM, Lorenz <[email protected]> wrote:
>
> > > Hi ,
> > > I've some problem reading a file. First of all I've created a new
> > > file ,and from the FileExplorer of Eclipse I'm able to find it but I
> > > can't open it and read it(it seems also that the file "Datacoord.dat"
> > > is empty, as a matter of fact the size showed by the FileExplorer is
> > > 0).
> > > However I want to read a file, what is the right sintax? Can I create
> > > file out of the data/data/mypackage/files ??
> > > I post my code:
>
> > > PrintWriter savedpoint = new PrintWriter(openFileOutput
> > > ("Datacoord.dat",MODE_APPEND));
>
> > >        for(int i=0;i<20;i++)
> > >        {
> > >                savedpoint.println("-78.443221"+i+" "+"120.344423");
>
> > >        }
> > > Is this rigth to write on a file?
> > > Please write the sintax to read a file..Thanks in advance!
>
> > --
> > Regards,
> > Michael Leunghttp://www.itblogs.infohttp://www.michaelleung.info
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to