Results 1 to 3 of 3
  1. #1
    Durge is offline Member
    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Default Passing RandomAccessFile stream to another method

    Hi,

    Wasn't sure where to post this. I am relative newcomer to Java, and have jumped into Android programming, and I am not sure whether my problem is a Java or Android issue.

    I am writing a program that processes Exif data, by directly accessing jpg files. The program has been fully tested and run in C#.net, and Copy and Pasted it over to Eclipse, making all the necessary changes. Obviously the languages are not the same, but I am still getting used to the little quirks of Java.

    It is in a class, which opens a jpg file in one method, and then gets data from another method, which is passed the filestream, in the form of a RandomAccessFile... like so...

    Java Code:
    private ExifTagData ExifTag(int tagID, RandomAccessFile ras) {
    As soon as I first reference the filestream...

    Java Code:
    startFilePosition = ras.getFilePointer();
    ...a nullPointerException is thrown. Please confirm that it is not possible to pass a stream to another method. It is not a major problem, as I can easily close the file, and re-open it again in the right place, I just want to make sure I understand things right.

    Thanks in advance.

  2. #2
    ContoNick is offline Member
    Join Date
    Dec 2011
    Location
    Croatia,Zagreb
    Posts
    24
    Rep Power
    0

    Default Re: Passing RandomAccessFile stream to another method

    Hello,

    make sure that passed object is not null before u use it inside method.

  3. #3
    Durge is offline Member
    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Default Re: Passing RandomAccessFile stream to another method

    Thanks for the reply,

    It shouldn't have been null, as it was already been used prior to being passed to the called Method. I solved the problem by closing the file, and passing the filename instead, and re-opening it within the method. The reason why I want to keep the filestream open is that as I am working through the file, I want to keep the position in the file, which is solved by adding a global variable for the pointer.

    I might not have needed to do that in the end, I think it is more to do with my unfamiliarity with Eclipse, and using the debugger.

Similar Threads

  1. Need help using RandomAccessFile writeByte Method
    By ii88xix88ii in forum JCreator
    Replies: 10
    Last Post: 01-31-2013, 02:33 PM
  2. Passing method as argument
    By susieferrari in forum New To Java
    Replies: 26
    Last Post: 06-13-2011, 11:43 AM
  3. Http Input Stream read method
    By chandan.mishra in forum Advanced Java
    Replies: 2
    Last Post: 01-03-2011, 03:36 AM
  4. standard input stream storing to a generic method?
    By vendetta in forum New To Java
    Replies: 3
    Last Post: 01-29-2010, 09:13 PM
  5. TCP/IP Client program halts at the read method of the stream
    By PradeepBadiger in forum Networking
    Replies: 0
    Last Post: 03-26-2009, 04:14 PM

Posting Permissions

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