Java Programming - Problem with java.io.Reader

Hello!

I have written the following code on jdk 6

package hmm;

import java.io.FileReader;

import java.io.Reader;

import java.util.Vector;

import be.ac.ulg.montefiore.run.jahmm.io.ObservationSequencesReader;

import be.ac.ulg.montefiore.run.jahmm.io.ObservationVectorReader;

public class papa {

Reader reader = new FileReader("test.seq");

Vector v = ObservationSequencesReader.

readSequences(new ObservationVectorReader(), reader);

reader.close();

}

The eclipse environment i am using indicates that the reader.close() statement is wrong and marks the "close" method writing

Syntax error on token "close";Identifier expected after this token

I really dont know the cause of this problem because the it was taken directly from a help file in the jahmm library (http://www.run.montefiore.ulg.ac.be/~francois/software/jahmm/)

i am using.

I have added this library at the build path and as you can see from the import statements i use some methods from it.

I would be grateful if someone could help me soon,as fixing this code is an essential piece of my thesis work..!!

Thank you in advance!

Harris

[1275 byte] By [csfyrakisa] at [2007-11-26 23:23:17]
# 1

Note that this code is placed outside any method, constructor or initializer block:

Reader reader = new FileReader("test.seq");

Vector v = ObservationSequencesReader.

readSequences(new ObservationVectorReader(), reader);

reader.close();

Just as you can't do this:

class Bad {

//just inside class!

for(int i=0; i < 10; ++i) {

//..

}

}

you can't stick reader.close(); where it is. That looks like code that should

be in a method, or at least a constructor.

DrLaszloJamfa at 2007-7-10 14:28:59 > top of Java-index,Java Essentials,Java Programming...
# 2
Thank you very much for your feedback!!
csfyrakisa at 2007-7-10 14:28:59 > top of Java-index,Java Essentials,Java Programming...