CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Compile error for FileReader

  1. #1
    Join Date
    Dec 2004
    Posts
    61

    Compile error for FileReader

    Dear Gurus,

    i have a question here.
    I'm developing a mobile program using netbeans IDE. Because the application need to store data so i use FileReader. But when i code my application using FileReader's member function/variable, i have error. My IDE not able to find the symbol of FileReader.

    The platform for my application is CDLC/MIDP.
    I have import the Java.io.* in the beginning of the file.

    My question is:
    1. Can JDK1.5 library add in to the CDLC/MIDP platform? If can, can you show me how.
    2. If not using FileReader, what other library that i can use to manage the data in a mobile application?

    Thanks.
    Attached Images Attached Images  

  2. #2
    Join Date
    Feb 2003
    Location
    Sunny Glasgow!
    Posts
    258

    Re: Compile error for FileReader

    If you single left click on the wee yellow icon you will get a suggested solution to the problem in Eclipse.

  3. #3
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Compile error for FileReader

    I have import the Java.io.* in the beginning of the file.
    If you want to import the io package you need to import java.io.* and not Java.io.*. Java is case sensitive.

    Having said that unless the java.io package is part of J2ME or is in one of the optional packages then you can't use it. I've never done any mobile work myself so have no idea but I guess you could just look in the API documentation for J2ME and see if it is there.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  4. #4
    Join Date
    Mar 2010
    Posts
    74

    Re: Compile error for FileReader

    generally speaking, Netbeans prompts you, what u need to import/
    only agree with NB.
    click right mouse on error sign and select Import pckage.

  5. #5
    Join Date
    Dec 2004
    Posts
    61

    Unhappy Re: Compile error for FileReader

    Dear keang,

    i have check my coding, my import is correct java.io.*
    is was typing error in my previous post.

    Dear themoffster and jitechno,

    i have try the right click and left click.
    1.When using the left click, the NB create a new FileReader class for me. which ask me to re-write the FileReader class all over again. i just want to use the class.

    2.when using the right click, there was nothing i can do much. it just like a navigator.

    you may refer to the attachment for more details.

    How can i solve this problem? Do i need to create my own's FileReader?
    Thanks.
    Attached Images Attached Images    

  6. #6
    Join Date
    Mar 2010
    Posts
    74

    Re: Compile error for FileReader

    No need create own FileReader

    1. Do you have this import?
    import java.io.FileReader;
    I see red error sign in yoour screen on a top of page, but I dont see code there. It is out of screen.

    2. Delete you java.io import
    and try again using clicks..

    3. If things still gping bad, put all code here.

  7. #7
    Join Date
    Dec 2004
    Posts
    61

    Re: Compile error for FileReader

    Dear jitechno,

    1.I have import the java.io.* at the top of my file.

    one thing that i think i have did wrong is i did not install the j2 SDK SE v1.4.2
    after i have install this SDK, the problem still remain. The NetBeans still said cannot find symbol.

    here is the coding:
    //at the top of the file

    package SortScore;

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    import javax.microedition.midlet.MIDlet;
    import javax.microedition.lcdui.*;
    import javax.microedition.rms.*;
    import java.io.DataOutputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.ByteArrayInputStream;
    import java.io.DataInputStream;
    import java.io.EOFException;

    import java.io.*; //if i change this line to import java.io.FileReader
    //the compiler will said cannot find symbol.

    ...
    //anything related to FileReader is not recognize.
    private void ReadFromTXT()
    {
    try
    {
    FileReader fro = new FileReader( "myFile.txt" );
    BufferedReader bro = new BufferedReader( fro );

    // declare String variable and prime the read
    String stringRead = bro.readLine( );

    while( stringFromFile != null ) // end of the file
    {
    System.out.println(stringFromFile);
    stringFromFile = bro.readLine( ); // read next line
    }

    bro.close( );
    }

    catch( FileNotFoundException filenotfoundexxption )
    {
    System.out.println( "myFile.txt, does not exist" );
    }

    catch( IOException ioexception )
    {
    ioexception.printStackTrace( );
    }
    }

    do you have any idea on this?
    Attached Images Attached Images  

  8. #8
    Join Date
    Mar 2010
    Posts
    74

    Re: Compile error for FileReader

    Midlet?
    but midlets work with rEDUCED SE , not complete one..

  9. #9
    Join Date
    Mar 2010
    Posts
    74

    Re: Compile error for FileReader

    must be method getText, something like it:

    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import java.io.*;

    public class SampleMIDlet extends MIDlet implements CommandListener{
    bla bla bla...

    String str=getText("book.txt");


    try to find examples for "get text from file, midlets"

  10. #10
    Join Date
    Jun 2007
    Location
    Aurora CO USA
    Posts
    137

    Re: Compile error for FileReader

    if you look at the API docs, You can see that FileReader is not part of the API.

    NetBeans is enforcing this through the libraries it provides. That's why you can't import or use it.

  11. #11
    Join Date
    Dec 2004
    Posts
    61

    Re: Compile error for FileReader

    Dear all,

    Thanks for showing where i'm wrong.
    I know that i have use the wrong library to do the coding.
    I have go through the API.

    i need to use the java.io.* but not the FileReader.
    Thanks for solving my problem.
    Thanks again.

  12. #12
    Join Date
    Mar 2010
    Posts
    74

    Re: Compile error for FileReader

    Ok, thanks for nice words,
    but is your problem closed?

  13. #13
    Join Date
    Dec 2004
    Posts
    61

    Re: Compile error for FileReader

    Dear Jitechno,

    Thanks for asking.
    actually i'm not sure what should i use to store my data.

    From the internet, i saw:
    1.Record Management System (RMS)
    2.FileOutputStream
    3.can use JDBC to run under the midlet application?

    i'm not sure what to use. maybe you can show me what should i use.
    Thanks.

  14. #14
    Join Date
    Mar 2010
    Posts
    74

    Re: Compile error for FileReader

    Quote Originally Posted by VbEndUser View Post
    Dear Jitechno,

    Thanks for asking.
    actually i'm not sure what should i use to store my data.

    From the internet, i saw:
    1.Record Management System (RMS)
    2.FileOutputStream
    3.can use JDBC to run under the midlet application?

    i'm not sure what to use. maybe you can show me what should i use.
    Thanks.
    hmm.. but it depends what kind of data, where and how you want keep.

    I dont think JDBC is a right selection for mobile app.
    FileOutputStream allows you keep data as files, at least.
    About What kind of RMS are you talking?

  15. #15
    Join Date
    Dec 2004
    Posts
    61

    Re: Compile error for FileReader

    Dear Jitechno,

    about the RMS, This is what i get from the internet:

    Record Management System Basics The Mobile Information Device Profile (MIDP) defines a set of classes for storing and retrieving data. These classes are called the Record Management System (RMS). With the RMS, it's possible to make data persist across invocations of a MIDlet. Different MIDlets in the same MIDlet suite can also use the RMS to share data...

    you can refer to this site:
    http://www.palowireless.com/Java/tutorials.asp

    yesterday, i have try to use the FileOutputstream but the netBeans give me a compile error saying "can not find symbol".
    same as the problem i face in my first post (for "FileReader").

    i have search the internet and found the java.io.* have a lot of function. This include the
    1.FileReader
    2.FileStream and etc.

    but my java.io.* only have very few function. maybe you can have a look at the printscreen.
    Is that the function that can support when we use the "Java wireless toolkit WTK2.5.2 for CDL"?

    Means java.io.* only have the very basic function in platform "Java wireless toolkit WTK2.5.2 for CDL".
    When you develop a true java application, then you can get to access to all the java.io.* function,which is more that the mobility platform?
    thanks.
    Attached Images Attached Images  

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)