Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: problem in j2me

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Location
    Home-Ujjain /Job-Mumbai
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default problem in j2me

        public Student[] getStudents()
        {
            Student[] student=null;
            try
            {
                int pin=0;String name=null;
                byte[] byteInputData = new byte[100];
                RecordStore rs=Utility.getStudentRecordStore();
                ByteArrayInputStream inputStream = new ByteArrayInputStream(byteInputData);
                DataInputStream inputDataStream =new DataInputStream(inputStream);
                int noOfRecords=rs.getNumRecords();
                student=new Student[noOfRecords];
                for (int x = 1; x <= rs.getNumRecords(); x++)
                {
                    rs.getRecord(x, byteInputData, 0);
                    name=inputDataStream.readUTF();
                    pin=inputDataStream.readInt();
                    student[x-1].setName(name);
                    student[x-1].setPin(pin);
                    inputStream.reset();
                }
                inputStream.close();
                inputDataStream.close();
                return student;
            }
            catch (Exception error)
            {
            }
            return student;
        }


    QQ. Above method is not returning array of students although the student.length is providing a proper answer please help me
    Last edited by Sunil Raghuvanshi; March 9th, 2010 at 04:59 AM.


  2. #2
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    490
    Thanks
    8
    Thanked 46 Times in 44 Posts

    Default Re: problem in j2me

    Don't eat exceptions. At the very least, print the stack trace.
      catch (Exception error) {
        error.printStackTrace();
      }
    Also, it's never recommended to catch Exception but rather the specific Exception subclass.

    db

  3. The Following User Says Thank You to Darryl.Burke For This Useful Post:

    JavaPF (March 18th, 2010)

Similar Threads

  1. Database synchronization from RMS with MySQL in Online mode
    By jeremyraj in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: January 24th, 2011, 07:08 AM
  2. J2EE and J2ME projects
    By vmwelt in forum Paid Java Projects
    Replies: 0
    Last Post: August 12th, 2009, 04:13 PM
  3. Sending and Receiving mail using J2ME without server
    By chals in forum Java ME (Mobile Edition)
    Replies: 5
    Last Post: June 2nd, 2009, 09:59 AM
  4. Runtime exception while developing J2ME mobile application with aspectJ
    By yousef atya in forum Java ME (Mobile Edition)
    Replies: 3
    Last Post: April 29th, 2009, 09:55 AM