Perry Smith

Java Questions & Answers

Home / Java Q & A Page 2 / Java Q & A Archive Main Page

file creation
 Friday, 30-Oct-98 08:11:53

      209.58.48.229 writes:

      I'm just recently begun to learn java and my programming background is not very strong so excuse me if this question
      sounds a little stupid.

      My question is: How do I create files in Java?. I mean, if I'm working with an application that handles data and I want
      to save that data to a file how do I do it?

      elbert fernandez


Responses

Re: file creation
 Friday, 30-Oct-98 20:02:20

      152.205.252.251 writes:

      before the class definition include this line

      import java.io.FileOutputStream;

      String strFileName

      // do stuff to get appropriate filename

      try
      {
      FileOutputStream fosCreate = new FileOutputStream(strFileName);
      }
      catch (java.io.IOException excpIOE)
      {
      System.exit(0); // for now...
      }

      Byte byteData

      // do stuff to assign byteData a nice value
      fosCreate.write(byteData);



      MikeD

Home / Java Q & A Page 2 / Java Q & A Archive Main Page