1 package ca.uhn.hl7v2.examples;
2
3 import java.io.BufferedInputStream;
4 import java.io.File;
5 import java.io.FileInputStream;
6 import java.io.FileNotFoundException;
7 import java.io.InputStream;
8
9 import ca.uhn.hl7v2.model.Message;
10 import ca.uhn.hl7v2.util.Hl7InputStreamMessageIterator;
11 import ca.uhn.hl7v2.util.Hl7InputStreamMessageStringIterator;
12
13 public class ReadMessagesFromFile {
14
15 @SuppressWarnings("unused")
16 public static void main(String[] args) throws FileNotFoundException {
17
18
19
20
21
22
23
24
25 File file = new File("hl7_messages.txt");
26 InputStream is = new FileInputStream(file);
27
28
29 is = new BufferedInputStream(is);
30
31
32
33 Hl7InputStreamMessageIterator iter = new Hl7InputStreamMessageIterator(is);
34
35 while (iter.hasNext()) {
36
37 Message next = iter.next();
38
39
40
41 }
42
43
44
45
46
47
48 file = new File("hl7_messages.txt");
49 is = new FileInputStream(file);
50 is = new BufferedInputStream(is);
51 Hl7InputStreamMessageStringIterator iter2 = new Hl7InputStreamMessageStringIterator(is);
52
53 while (iter2.hasNext()) {
54
55 String next = iter2.next();
56
57
58
59 }
60
61 }
62
63 }