2
* Cobertura - http://cobertura.sourceforge.net/
4
* Copyright (C) 2006 John Lewis
5
* Copyright (C) 2006 Mark Doliner
7
* Note: This file is dual licensed under the GPL and the Apache
8
* Source License 1.1 (so that it can be used from both the main
9
* Cobertura classes and the ant tasks).
11
* Cobertura is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published
13
* by the Free Software Foundation; either version 2 of the License,
14
* or (at your option) any later version.
16
* Cobertura is distributed in the hope that it will be useful, but
17
* WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
* General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with Cobertura; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27
package net.sourceforge.cobertura.ant;
29
import java.io.BufferedReader;
30
import java.io.ByteArrayOutputStream;
32
import java.io.FileNotFoundException;
33
import java.io.FileReader;
34
import java.io.IOException;
35
import java.io.PrintStream;
40
static File createTemporaryTextFile(String prefix) throws IOException
43
outputFile = File.createTempFile(prefix, ".txt");
44
outputFile.deleteOnExit();
49
* Returns the text of a file as a string.
51
* @param file The file to read.
52
* @return A string containing the text of the file
54
static String getText(File file) throws FileNotFoundException, IOException
56
ByteArrayOutputStream baos = new ByteArrayOutputStream();
57
PrintStream ps = new PrintStream(baos);
58
BufferedReader reader = null;
61
reader = new BufferedReader(new FileReader(file));
63
while ((line = reader.readLine()) != null)
80
System.err.println("IOException when closing file " + file.getAbsolutePath());
86
return baos.toString();