You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Chetan <ch...@bhavishya.net> on 2006/01/10 11:10:00 UTC

Need help in java code - Write into Text file

Hi,

I am chetan from India, I have developed the WebSite www.bhavishya.net. I am encountering a serious problem in writing into a text file. I am unable to configure the path of the text file. while using Linux i got it. but now i am using Windows Environment. The code is as follows.

public String ewrite(String str)
    {
  String err = "File updated";
  try 
      {
    Date d = new Date();
    BufferedWriter bwout = null;
    // for Web Server 
    try 
        {
      //BufferedWriter out = new BufferedWriter(new FileWriter("/home/bhavishya/ErrorLog.txt", true)); // For Linux
      bwout = new BufferedWriter(new FileWriter("./bhavishya/logs/ErrorLog.txt", true));
      bwout.write(d.toLocaleString()+" : "+str+"\n");
        }
    catch (RuntimeException e1) {err = e1.toString(); e1.printStackTrace();}
    System.out.println("ErrorLog - 21");
    bwout.close();
      }
  catch (IOException e) { System.out.println(e); }
  return err;
    }


Regards,
Chetan
9885-301302

BHAVISHYA is a premier futures broker with over 115 commodity traders in 8 offices to service all of your indian and international commodities, alternative investments, trading needs, day trading, futures brokers, futures trading, forex trading, currency trading, managed futures, stock trading, share trading, and personalised Portfolio Management.
Log on to  http://www.bhavishya.net for further details.