6 Replies Latest reply: Oct 16, 2010 7:07 PM by Darryl Burke RSS

    Cannot Compile when using FileInputStream

    805972
      I am trying to read data from a file...

      I cannot compile this and I have tried importing all of the java.io.* classes and it still does not compile.

      Help!


      I have the following imports:

      import net.rim.device.api.ui.*;
      import net.rim.device.api.system.Application;
      import javax.microedition.io.*;
      import javax.microedition.io.file.*;
      import java.io.*;
      import net.rim.device.api.ui.component.*;
      import net.rim.device.api.ui.container.*;
      import net.rim.device.api.system.Bitmap;
      import net.rim.device.api.system.*;
      import JavaProjects.JDE42.EmergInfo.Resource.*;
      import net.rim.device.api.i18n.*;


      And the code snippet:

      private void ReadDataFile()
      {
      try {

      FileInputStream fstream = new FileInputStream(_resources.getString(EmergInfoResResource.DWI_DATAFILE));

      DataInputStream in = new DataInputStream(fstream);
      BufferedReader br = new BufferedReader(new InputStreamReader(in));
      String strLine;
      //Read File Line By Line
      while ((strLine = br.readLine()) != null) {
      // Print the content on the console
      System.out.println (strLine);
      }
      //Close the input stream
      in.close();
      }catch (Exception e){//Catch exception if any
      System.err.println("Error: " + e.getMessage());
      }
      }

      On compile, I get the following errors:

      Building EmergInfo_DWI
      C:\Program Files\Research In Motion\BlackBerry JDE 5.0.0\bin\rapc.exe -quiet codename=EmergInfo_DWI EmergInfo_DWI.rapc warnkey=0x52424200;0x52525400;0x52435200 import="C:\Program Files\Research In Motion\BlackBerry JDE 5.0.0\lib\net_rim_api.jar" D:\JavaProjects\JDE42\EmergInfo\img\DWI_Main.jpg D:\JavaProjects\JDE42\EmergInfo\img\DWI_Main_bw.jpg D:\JavaProjects\JDE42\EmergInfo\Resource\EmergInfoRes.rrc D:\JavaProjects\JDE42\EmergInfo\Resource\EmergInfoRes.rrh D:\JavaProjects\JDE42\EmergInfo\Source\DWI_Main.java D:\JavaProjects\JDE42\EmergInfo\Source\DWI_Main_Screen.java
      D:\JavaProjects\JDE42\EmergInfo\Source\DWI_Main.java:68: cannot find symbol
      symbol : class FileInputStream
      location: class Source.DWI_Main
      FileInputStream fstream = new FileInputStream(_resources.getString(EmergInfoResResource.DWI_DATAFILE));
      ^
      D:\JavaProjects\JDE42\EmergInfo\Source\DWI_Main.java:68: cannot find symbol
      symbol : class FileInputStream
      location: class Source.DWI_Main
      FileInputStream fstream = new FileInputStream(_resources.getString(EmergInfoResResource.DWI_DATAFILE));
      ^
      D:\JavaProjects\JDE42\EmergInfo\Source\DWI_Main.java:72: cannot find symbol
      symbol : class BufferedReader
      location: class Source.DWI_Main
      BufferedReader br = new BufferedReader(new InputStreamReader(in));
      ^
      D:\JavaProjects\JDE42\EmergInfo\Source\DWI_Main.java:72: cannot find symbol
      symbol : class BufferedReader
      location: class Source.DWI_Main
      BufferedReader br = new BufferedReader(new InputStreamReader(in));
      ^
      4 errors