Hello,
I am trying to access a binary file with scanner functionality. I am trying to extract integer, long double value from the binary file.
The binary file formation is as follows
The binary file is in little Endian and is structured as follows:
*
* <ul>
* <li>1 integer: containing the number of signals in the file = <b>N</b>.
* <li><b>N</b> signal descriptions, each consisting of:
* <ul>
* <li>0 (zero) terminated ANSI ASCII byte string which is the signal name.
* <li>0 (zero) terminated ANSI ASCII byte string which is the signal unit.
* <li>1 integer designating the data type <b>T</b> according to the ordinal of the enums
* in DataType.
* </ul>
* <li><b>M</b> Data sets: One value for each signal according to its data type <b>T</b>,
* * i.e. <b>N</b> values per data set. Data sets repeat until the end of the file.
* </ul>
Now I am trying to do the following
public void open(File filelocation) throws FileNotFoundException, IOException {
dis = new Scanner (filelocation).useDelimiter("\\s*0\\s*");
}
@Override
public void close() throws IOException {
// TODO Auto-generated method stub
dis.close();
}
@Override
public List<SignalExtract> getSignals() {
public List<SignalExtract> getSignals() {
while ((dis).hasNext()) {
System.out.println("access");
container.index=dis.nextInt();
container.signalname = dis.next();
container.signalunit = dis.next();
decision = dis.hasNextInt();
if(decision==true)
{
enumdecision = dis.nextInt();
if(enumdecision == 1)
{
container.timeinsecond = dis.nextLong();
}
if(enumdecision == 2)
{
container.doublevalue = dis.nextDouble();
}
}
userList.add(container);
}
return userList;
}
**
Any help will be appriciated.