~ubuntu-branches/ubuntu/oneiric/tuxguitar/oneiric

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/help/about/AboutContentReader.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mfrom: (1.1.1 upstream) (2.1.3 hardy)
  • Revision ID: james.westby@ubuntu.com-20080619003030-agens2gvd5m4dacu
New upstream release (Closes: #481728) also (LP: #176979, #212207)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.herac.tuxguitar.gui.help.about;
 
2
 
 
3
import java.io.IOException;
 
4
import java.io.InputStream;
 
5
 
 
6
import org.herac.tuxguitar.gui.TuxGuitar;
 
7
import org.herac.tuxguitar.util.TGClassLoader;
 
8
 
 
9
public class AboutContentReader {
 
10
        
 
11
        private static final String PREFIX = "about_";
 
12
        private static final String EXTENSION = ".dist";
 
13
        
 
14
        public static final String DESCRIPTION = "description";
 
15
        public static final String AUTHORS = "authors";
 
16
        public static final String LICENSE = "license";
 
17
        
 
18
        public AboutContentReader(){
 
19
                super();
 
20
        }
 
21
        
 
22
        public StringBuffer read(String doc){
 
23
                String lang = TuxGuitar.instance().getLanguageManager().getLanguage();
 
24
                InputStream is = TGClassLoader.instance().getClassLoader().getResourceAsStream(PREFIX + doc + "_" + lang + EXTENSION);
 
25
                if(is == null){
 
26
                        is = TGClassLoader.instance().getClassLoader().getResourceAsStream(PREFIX + doc + EXTENSION);
 
27
                }
 
28
                if(is != null){
 
29
                        return read(is);
 
30
                }
 
31
                System.out.println(doc + ".txt");
 
32
                
 
33
                return new StringBuffer();
 
34
        }
 
35
        
 
36
        public StringBuffer read(InputStream is){
 
37
                StringBuffer sb = new StringBuffer();
 
38
                try {
 
39
                        int length = 0;
 
40
                        byte[] buffer = new byte[1024];
 
41
                        while((length = is.read(buffer)) != -1){
 
42
                                sb.append(new String(buffer,0,length));
 
43
                        }
 
44
                        is.close();
 
45
                } catch (IOException e) {
 
46
                        e.printStackTrace();
 
47
                }
 
48
                return sb;
 
49
        }
 
50
}