Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package org.litesoft.utils;

import java.io.*;

public class FileUtils {
    public static final String UTF_8 = "UTF-8";

    public static String loadTextFileAsString( InputStream pInputStream, String pLineSeparator )
            throws IOException {
        StringBuilder buffer = new StringBuilder();
        BufferedReader reader = createReader( pInputStream );
        boolean closed = false;
        try {
            int count = 0;
            for ( String line; null != (line = reader.readLine()); count++ ) {
                if ( count > 0 ) {
                    buffer.append( pLineSeparator );
                }
                buffer.append( line );
            }
            closed = true;
            reader.close();
        }
        finally {
            if ( !closed ) {
                try {
                    reader.close();
                }
                catch ( IOException ignore ) {
                    // Whatever...
                }
            }
        }

        return buffer.toString();
    }

    public static BufferedReader createReader( InputStream pInputStream )
            throws IOException {
        return new BufferedReader( new InputStreamReader( pInputStream, UTF_8 ) );
    }
}

Commits for litesoft/trunk/DeviceDesktopTest/src/org/litesoft/utils/FileUtils.java

Diff revisions: vs.
Revision Author Commited Message
961 Diff Diff GeorgeS picture GeorgeS Fri 01 Aug, 2014 03:13:31 +0000

Externalization Work.

927 GeorgeS picture GeorgeS Mon 17 Mar, 2014 03:58:40 +0000

Template system and index.html as a resource...