Projekt

Obecné

Profil

« Předchozí | Další » 

Revize f5b17319

Přidáno uživatelem Tomáš Šimandl před téměř 6 roky(ů)

Removed unused class

Zobrazit rozdíly:

sources/src/main/java/cz/zcu/kiv/offscreen/graph/loader/DemoDiagramLoader.java
1
package cz.zcu.kiv.offscreen.graph.loader;
2

  
3
import java.io.BufferedReader;
4
import java.io.Closeable;
5
import java.io.InputStream;
6
import java.io.InputStreamReader;
7

  
8
import org.apache.log4j.Logger;
9

  
10
public class DemoDiagramLoader {
11

  
12
	private Logger logger = Logger.getLogger(DemoDiagramLoader.class);
13

  
14
	/**
15
	 * Reads an input file specified by request.
16
	 *
17
	 * @param in Input stream with JSON data.
18
	 * @return JSON string
19
	 */
20
	public String readDemoJSONFromFile(InputStream in) {
21

  
22
		BufferedReader reader = new BufferedReader(new InputStreamReader(in));
23

  
24
		StringBuilder builder = new StringBuilder();
25
		String line;
26

  
27
		try {
28
			while ((line = reader.readLine()) != null) {
29
				builder.append(line);
30
			}
31

  
32
		} catch (Exception e) {
33
			e.printStackTrace();
34
			logger.error("ERROR at file reading");
35
		} finally {
36
			closeQuietly(in);
37
			closeQuietly(reader);
38
		}
39

  
40
		return builder.toString();
41
	}
42

  
43
	/**
44
	 * Closes quietly a stream.
45
	 *
46
	 * @param stream Input stream to close.
47
	 */
48
	private void closeQuietly(Closeable stream) {
49
		if (stream != null) {
50
            try {
51
                stream.close();
52
            } catch (Exception e) {
53
                // ignore
54
                e.printStackTrace();
55
            }
56
        }
57
	}
58
}

Také k dispozici: Unified diff