Package: ProcessConsolePrinter

ProcessConsolePrinter

nameinstructionbranchcomplexitylinemethod
ProcessConsolePrinter(File, InputStream)
M: 18 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
ProcessConsolePrinter(File, InputStream, String)
M: 21 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
run()
M: 64 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 14 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * Test Framework for Overture
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.test.util;
23:
24: import java.io.BufferedReader;
25: import java.io.BufferedWriter;
26: import java.io.File;
27: import java.io.FileWriter;
28: import java.io.IOException;
29: import java.io.InputStream;
30: import java.io.InputStreamReader;
31:
32: public class ProcessConsolePrinter extends Thread
33: {
34:         File file = null;
35:         InputStream stream = null;
36:         String headerMessage = null;
37:
38:         public ProcessConsolePrinter(File file, InputStream inputStream)
39:         {
40:                 this.file = file;
41:                 this.stream = inputStream;
42:         }
43:
44:         public ProcessConsolePrinter(File file, InputStream inputStream,
45:                         String headerMessage)
46:         {
47:                 this.file = file;
48:                 this.stream = inputStream;
49:                 this.headerMessage = headerMessage;
50:         }
51:
52:         @Override
53:         public void run()
54:         {
55:
56:                 String line = null;
57:                 BufferedReader input = new BufferedReader(new InputStreamReader(stream));
58:                 FileWriter outputFileReader;
59:                 try
60:                 {
61:                         outputFileReader = new FileWriter(file, false);
62:                         BufferedWriter outputStream = new BufferedWriter(outputFileReader);
63:•                        if (headerMessage != null)
64:                         {
65:                                 outputStream.write("\n" + headerMessage + "\n");
66:                                 outputStream.flush();
67:                         }
68:•                        while ((line = input.readLine()) != null)
69:                         {
70:                                 outputStream.write("\n" + line);
71:                                 outputStream.flush();
72:                         }
73:
74:                         outputStream.close();
75:                 } catch (IOException e)
76:                 {
77:
78:                 }
79:         }
80: }