How do you read from and write to a file in Visual J#

I need help as soon as posible. My problem is that reading from a file in J# is different then in Java. I have looked all over the place and still hae not found out how to do this.

I need the help for a Final project that is currently in progress. If any on can help I would really appritiate it.


Answer this question

How do you read from and write to a file in Visual J#

  • John Finney

    Hi,

    There are no of stream classes available in java.io package. Just import this package in your code file.

    You could use System.IO package also. For example...

    For reading from a file...

    System.IO.StreamReader hLogFileRdr = new System.IO.StreamReader(<filename>);
    while (!(hLogFileRdr.get_EndOfStream() ))
    {
       String currStr = hLogFileRdr.ReadLine();
       ..
       ..
    }

    For writing to a file...

    System.IO.StreamWriter logFileWrtr=new System.IO.StreamWriter(<filename> ,<append>);
    logFileWrtr.WriteLine(<string>);


    Hope it helps.

    Thanks.



  • Mike_maul

    Thanks for the information. It is very use full and was much needed.

    Although a do not want to say it I did not need it after all, I figured it out just before I came back to see if any one had an aswer to my question.

    Thank you any way.

    thanks.

  • How do you read from and write to a file in Visual J#