Re: Re: [TINI]SLush and File Writing

"伟大" <zhbnzz-9Onoh4P/[email protected]>
Newsgroups gmane.comp.hardware.microcontrollers.tini
Message-ID <[email protected]>
Dear Richard Southey

My application code (myApp.java) in slush can reads data from file in SRAM, but cannot writes data to file in SRAM. Why?

//======================1===================================
 boolean ret=false;
 DSFile ff = new DSFile("datafile");
 try{
      PrintStream ffOut = new PrintStream(new BufferedOutputStream(new FileOutputStream(ff)));
      ffOut.println("12345");
      ffOut.println("67890");
      ffOut.flush(); 
      ffOut.close();
      ff.setOtherPermissions(0);
 }catch(IOException e)
              {
}
//=========================================
The above code in "myApp.java", “datafile” not  found in SRAM. Why?
The above code in "slush.java", “datafile”  found in SRAM. Why?


//====================2====================
FileOutputStream ffout;
try
 {
  ffout= new FileOutputStream("datafile");
  ffout.write((new String("12345\r\n")).getBytes());
ffout.write((new String("67890\r\n")).getBytes());
ffOut.flush(); 
ffout.close();
}catch(IOException e)
              {
}
//=========================================
The above code in "myApp.java", “datafile” not  found in SRAM. Why?
The above code in "slush.java", “datafile”  found in SRAM. Why?

Best regards,
Zhbnzz
4.2.2004

> Try flushing the stream before you close it, to make sure the string is 
> actually written:
> 
>          writer.flush();
> 
> If the buffer is not filled up, it will not always be written to the 
> file.  I've have had this problem on the PC many times, and it normally 
> takes me ages to work out why.
> 
> Hope this helps,
> 
> Cheers
> 
> Richard
> 
> At 19:24 30/03/2004, Swami Venkataramani wrote:
> >I wrote a program that writes a string to file (which already
> >exists).  However, when I added this program as a Slush command and added this
> >Slush command to the .startup file, it does not write to the file anymore. I
> >tried using the DSFile class too, and still it doesn't work...
> >
> >Some sample code:
> >
> >DSFile dfile = new DSFile ("mode.txt");
> >FileOutputStream dfileStream = new FileOutputStream (dfile);
> >PrintWriter writer = new PrintWriter(dfileStream);
> >writer.println(message);
> >writer.close ();
> >
> >
> >Any help is appreciated.
> >
> >Thanks,
> >
> >Swami.
> >
> >_______________________________________________
> >TINI mailing list
> >TINI-6tN4nzCoH/[email protected]
> >To UNSUBSCRIBE, edit your profile, or see list archives:
> >http://lists.dalsemi.com/mailman/listinfo/tini
> 
> 
> _______________________________________________
> TINI mailing list
> TINI-6tN4nzCoH/[email protected]
> To UNSUBSCRIBE, edit your profile, or see list archives:
> http://lists.dalsemi.com/mailman/listinfo/tini
> 
========================================================
“掀起你的盖头来,AOC新妆靓丽健康秀”!            http://design.163.com/aocmonitor/index.html

是邮件你收 有病毒我上!VIP邮箱 全面保护!            http://vip.163.com

中国最大的免费邮箱在等你 25兆空间4兆附件!      http://mail.163.com

点击网易泡泡惊喜无限 全免费手机短信任你发!      http://popo.163.com
_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.