• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to read .eips file in Java ?

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone tell me the charset for reading .eips file ? I tried below, but some extra characters are reading and that is making my parsing logic breaks. In this eips file each record is in a particular position and my code is to read from that position, since extra spaces and characters are coming along with thsi stream , my code breaks. Can anyone please suggest something to get this resolved.



 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are reading extra characters, then I suspect your problem has nothing to do with choosing a charset. Choosing Cp1252 instead of ISO-8859-1, let's say, is going to make very little difference.

But when I search the web for information about the .eips file extension, I found nothing. The sites which claim to know everything about all file extensions have never heard of it. So I would suggest you talk to whoever gave you the file and ask for a description of the file format. Then if you have trouble writing code to read and interpret the file, post a question which describes your problem in detail. Starting from a proposed solution can be pointless if your proposed solution isn't a solution at all.
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is X937 file which shows the check details.
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems to me that the text data in that format is EBCDIC, but there's also binary data in the file. So if I'm reading the right documents (which is quite possible based on the amount of information you posted) then using an InputStreamReader is the wrong thing to do because it's going to try to interpret the binary data as EBCDIC text. You should read the text data in as binary data and then convert it to a String using a suitable encoding (which looks like it might be Cp1047 maybe).

But I still recommend posting a proper problem description.
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, This file is having extension .ecpi and it can be viewed in Image viewer and the record format is like below
01 – File Header Record
10 – Cash Letter Header Record
20 – Bundle Header Record
61 – Credit/Reconciliation Record
50 – Image View Detail Record (front of item)
52 – Image View Data Record (front of item)
50 – Image View Detail Record (back of item)
52 – Image View Data Record (back of item)

i want to read the record type say 20 . So in the X937 file position, i got to know that the record type is in the 1-2 position. So I made the logic of taking substring(1,2), but it is showing the first 4 position as blank and for some records the initial values are junk.

If you google the X937 image viewer, you can see the same..All the record type is in the first position and if i open the file in image viewer also i can the see the field in position 1.The same thing if im reading through InputStream reader, im getting some junk value and followed by the real value..So my logic of parsing breaks here.

Below the code snippet:





Expected value :25       06310215 555588886             001622/          013081516550000G01Y011

Actual value  :                 P25          0632015  555588886     001622/          013081516550000G01Y011
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


To me these constants seem to suggest that you're assuming fixed-length records of 80 bytes each. Is that what your documentation says? Because you seem to be finding that isn't the case.
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes each record is of length 80.
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please focus on the below code..I did some sysout to understand the file.
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any encoding or decoding i have to do here?? Please help
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tracked down a document which seems to describe an X9.37 standard and it says

The DSTU X9.37 - 2003 file is comprised of variable length records.

 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From here:
"
come-on...there are multiple valid standards for x9.37 files, and 40 standards surrounding the x9.37 files. Take a break with dilbert, and relish the sarcasm every once in a while.
"


That page seems to highlight wild variations.
There is a newer standard, but the doc'll set you back $100.

Here's another doc on the "standard".
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
record length for the eips file used is showing as 80 for all the checks.
here that is not my concern.I am just taking record 25 from all the files and want to read the record type in 1-2 position. please suggest a solution for that.
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about reading the file sequentially, once you get the data starting with 25 (the record number), read the string and split it get 1-2.
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if i m reading the file with InputStream like the code i mentioned above, it is showing some extra characters..
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is very hard to sort out remotely.
We still don't really know the format of the file.
What exactly is the structure?
Do you have an example of what one looks like?

Since you say it is always 80 bytes then it's clearly not the file type we've posted links to.
Leaves us flying blind I'm afraid.
 
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sree Lekshmi wrote:if i m reading the file with InputStream like the code i mentioned above, it is showing some extra characters..

"...each record is prefixed by a four byte size (big endian)." <- that info might related with what you get. Read this first to fully understand how the file is built > http://www.x937.com/ [edit] actually not that much info there too
 
Liutauras Vilda
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

x937.com wrote:While each record has a type, but there is a twist, the type doesn't completely define the definition of the record, some records also get their definition from other parts of the record data. (Technically, this is a bad design because it mixes interface and implementation, and is discouraged today, but this format is derived from historical formats).

Beware of that part, that could be tricky.

If I understood the quote above correctly, that not necessarily defines the correct information you're interested in.

Sree Lekshmi wrote:want to read the record type in 1-2 position

 
Liutauras Vilda
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably one thing you could do now is to make sure you have copies of those files before you do any Java readings or anything similar. Better is to play with files copies rather than originals as sometimes copies aren't exact copies.
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when i change the extension of the file to .txt and open in notepad this is the first line and which is what i am getting while reading... dont understand how that initial character come "NUll Null Null P"

NUll Null Null P0103T063102152063102152201608121316NXerox Day1 Proc
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please find out what encoding you are using in that file, and what encoding you are using to read it.
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes i want to check that...how can we find that..
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The encoding of the text parts of the file isn't going to have any effect on the length of the records.
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it is ANSI when i open in notepad
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a suggestion: Yes, I know there are hundreds of different possible formats for your file, but none of them are text-only. There's image data for cheques, which is binary, and other posters in this thread have raised the possibility of binary data for record lengths. So don't use a text editor to look at the file, because it won't handle the binary data correctly. Use a hex editor instead.

And once you have your file in a hex editor, scan down to where the "25" is which starts your record type 25. I predict it won't be at position 160 -- but we already know that because your code demonstrated it. Perhaps there are 4-byte binary record lengths preceding each record, and if there are you should see them immediately when you use the hex editor.

As for encodings, none of them are going to deal with binary data correctly. So searching for the "correct" encoding is a waste of time too.
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have hex editor and it shows the following.Attached the image. In this file i want to read all '25' record types,for that i have to read record type of all transaction. if the record type is not in a specified position( each records it shows record type in different position) how can i make a generic code ?
pos.jpg
[Thumbnail for pos.jpg]
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The hexeditor image shows a 4 byte binary/hex value 0x50/80/"P" which could be the length followed by the record.  The  record at the green square starts with "25", the next with "26" and the next with "50"
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm sorry..can you please elaborate? what is the position of "25" here? What if i want to read all records(20,52,26.25) ,I cannot write a generic code to read the position if it is not coming in same position right?
 
Norm Radder
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the hex display,
at location 08C2 is a 4 byte value (0x50) that looks like a length field.  
at location 08C6 is the start of the data for the record.  The first two characters are "25"
at location 0916 is a 4 byte value (0x50) - length  (note: 08C6 + 50 = 0916
at location 091A is start of data for record starting with: "26"


I don't know how you position to location 08C2. Once there, read the 4 bytes as an int for the length, then read that length of bytes for the record's data
then repeat: read 4 bytes length, read that amount of data
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess that helps..Will keep you posted..thanks much
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sree Lekshmi wrote:What if i want to read all records(20,52,26.25) ,I cannot write a generic code to read the position if it is not coming in same position right?



That's right, at least you can't write a simple piece of code. Basically you have to write code which extracts the records one at a time starting at the beginning of the file. You need code to read four bytes and convert them into a record length, call it R, and then code to read the next R bytes into a byte array which represents the record. Then if your record is supposed to be text (and not e.g. an image) you would convert those bytes to a String.

A DataInputStream would be useful to do this, because it has a method to read four bytes and give you an integer value. Although that "endian" business might be a problem. Anyway it looks like you're on the right path, the hex editor is a really useful tool for this kind of programming.
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to read hexadecimal position of file in java ? Is there any better approach. I don't have much idea about this, googled a lot and no luck:(
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below is my code , This is to taking first record type( 01 here) , But i can see positions are varying...I'm totally confused




Output

size 808529971

               P

Attaching my file in hex editor
1.jpg
[Thumbnail for 1.jpg]
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


In the first line you read the four bytes which are supposed to be the record length into a four-byte array. So far so good.

In the second line you read the next four bytes, interpreting them as an integer. Don't do that, the next four bytes are the first four bytes of your record data.
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would also be helpful if you didn't have all of that various logic in one giant "main" method. Put the logic for processing one file into a separate method at least.
 
Paul Clapham
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually it seems to me that you only need something like this:


 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you are right!! it is reading the length of first record. But I don't understand, it should read the entire file. right ? how come first record ? how can I go to the next record now ?
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK I got it what you meant.. I am coding based on my understanding..Will keep you posted:)
 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you guys, it worked!!
One more question now I am reading byte array to character and checking the position of record type '25', That code works fine- Now my question is If it is record type 25, i want to read a value from that record- I can read that value using char[i] position. is it a good way to read a long value ?

 
Sree Lekshmi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please ignore above code, this is the one


}
 
Check your pockets for water buffalo. You might need to use this tiny ad until locate a water buffalo:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic