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...
Code:
private ExifTagData ExifTag(int tagID, RandomAccessFile ras) {
As soon as I first reference the filestream...
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.
Re: Passing RandomAccessFile stream to another method
Hello,
make sure that passed object is not null before u use it inside method.
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.