We Recommend

Java How to Program Java How to Program
Takes a new tools-based approach to Web application development that uses Netbeans 5.5 and Java Studio Creator 2 to create and consume Web Services. Features new AJAX-enabled, Web applications built with JavaServer Faces (JSF), Java Studio Creator 2 and the Java Blueprints AJAX Components. Includes new topics throughout, such as JDBC 4, SwingWorker for multithreaded GUIs, GroupLayout, Java Desktop Integration Components (JDIC), and much more.


Posted By

javapda on 07/01/07


Tagged

file sun read SPOT bundled


Versions (?)


Sun SPOT read bundled file as resource


Published in: Java 


Shows reading a file bundled with a Sun SPOT application.
The file, called winners.txt contains the following 2 lines:
Walker
Griffin
-----------------------------------------------------------
The output would include:
NameOfFile=/winners.txt
line=Walker
line=Griffin


  1. public class GetAppPropertiesSpotApp extends MIDlet {
  2. protected void startApp() throws MIDletStateChangeException {
  3. String nameOfFile=this.getAppProperty("NameOfFile");
  4. System.out.println("NameOfFile=" + nameOfFile);
  5. InputStream is = getClass().getResourceAsStream(nameOfFile);
  6. String line = null;
  7. while ((line=br.readLine())!=null) {
  8. System.out.println("line=" + line);
  9. }
  10.  
  11. }
  12.  
  13. protected void pauseApp() {}
  14. protected void destroyApp(boolean arg0) throws MIDletStateChangeException {}
  15.  
  16. }

Report this snippet 

You need to login to post a comment.