1 | /* |
---|
2 | * This file is part of OpenModelica. |
---|
3 | * |
---|
4 | * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC), |
---|
5 | * c/o Linköpings universitet, Department of Computer and Information Science, |
---|
6 | * SE-58183 Linköping, Sweden. |
---|
7 | * |
---|
8 | * All rights reserved. |
---|
9 | * |
---|
10 | * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR |
---|
11 | * THIS OSMC PUBLIC LICENSE (OSMC-PL). |
---|
12 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE |
---|
13 | * OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, ACCORDING TO RECIPIENTS CHOICE. |
---|
14 | * |
---|
15 | * The OpenModelica software and the Open Source Modelica |
---|
16 | * Consortium (OSMC) Public License (OSMC-PL) are obtained |
---|
17 | * from OSMC, either from the above address, |
---|
18 | * from the URLs: http://www.ida.liu.se/projects/OpenModelica or |
---|
19 | * http://www.openmodelica.org, and in the OpenModelica distribution. |
---|
20 | * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html. |
---|
21 | * |
---|
22 | * This program is distributed WITHOUT ANY WARRANTY; without |
---|
23 | * even the implied warranty of MERCHANTABILITY or FITNESS |
---|
24 | * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH |
---|
25 | * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL. |
---|
26 | * |
---|
27 | * See the full OSMC Public License conditions for more details. |
---|
28 | * |
---|
29 | * Main author: Wladimir Schamai, EADS Innovation Works / Linköping University, 2009-now |
---|
30 | * |
---|
31 | * Contributors: |
---|
32 | * Uwe Pohlmann, University of Paderborn 2009-2010, contribution to the Modelica code generation for state machine behavior, contribution to Papyrus GUI adoptations |
---|
33 | * Parham Vasaiely, EADS Innovation Works / Hamburg University of Applied Sciences 2009-2011, implementation of simulation plugins |
---|
34 | */ |
---|
35 | package org.modelica; |
---|
36 | |
---|
37 | import java.io.InputStream; |
---|
38 | import java.io.InputStreamReader; |
---|
39 | import java.io.PrintStream; |
---|
40 | |
---|
41 | // TODO: Auto-generated Javadoc |
---|
42 | /** |
---|
43 | * The Class StreamReaderThread. |
---|
44 | */ |
---|
45 | public class StreamReaderThread extends Thread |
---|
46 | { |
---|
47 | |
---|
48 | /** The m out. */ |
---|
49 | PrintStream mOut; |
---|
50 | |
---|
51 | /** The m in. */ |
---|
52 | InputStreamReader mIn; |
---|
53 | |
---|
54 | /** |
---|
55 | * Instantiates a new stream reader thread. |
---|
56 | * |
---|
57 | * @param in |
---|
58 | * the in |
---|
59 | * @param out |
---|
60 | * the out |
---|
61 | */ |
---|
62 | public StreamReaderThread(InputStream in, PrintStream out) |
---|
63 | { |
---|
64 | mOut=out; |
---|
65 | mIn=new InputStreamReader(in); |
---|
66 | } |
---|
67 | |
---|
68 | /* (non-Javadoc) |
---|
69 | * @see java.lang.Thread#run() |
---|
70 | */ |
---|
71 | public void run() |
---|
72 | { |
---|
73 | int ch; |
---|
74 | try |
---|
75 | { |
---|
76 | while(-1 != (ch=mIn.read())) |
---|
77 | { |
---|
78 | mOut.append((char)ch); |
---|
79 | mOut.flush(); |
---|
80 | } |
---|
81 | } |
---|
82 | catch (Exception e) |
---|
83 | { |
---|
84 | mOut.append("\nRead error:"+e.getMessage()); |
---|
85 | } |
---|
86 | } |
---|
87 | } |
---|