rt/vm/src/test/java/org/apidesign/vm4brwsr/Resources.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sun, 27 Apr 2014 22:40:17 +0200
branchclosure
changeset 1493 234fea368401
parent 1491 rt/vm/src/test/java/org/apidesign/vm4brwsr/Numbers.java@4a1398eff4fb
child 1495 d5dd07b45f79
permissions -rw-r--r--
Initial infrastructure to export resources
jaroslav@114
     1
/**
jaroslav@114
     2
 * Back 2 Browser Bytecode Translator
jaroslav@114
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@114
     4
 *
jaroslav@114
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@114
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@114
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@114
     8
 *
jaroslav@114
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@114
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@114
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@114
    12
 * GNU General Public License for more details.
jaroslav@114
    13
 *
jaroslav@114
    14
 * You should have received a copy of the GNU General Public License
jaroslav@114
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@114
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@114
    17
 */
jaroslav@114
    18
package org.apidesign.vm4brwsr;
jaroslav@114
    19
jaroslav@181
    20
import java.io.IOException;
jaroslav@1493
    21
import java.io.InputStream;
jaroslav@181
    22
jaroslav@114
    23
/**
jaroslav@114
    24
 *
jaroslav@114
    25
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@114
    26
 */
jaroslav@1493
    27
public class Resources {
jaroslav@1493
    28
    public static String loadKO() throws IOException {
jaroslav@1493
    29
        InputStream is = Resources.class.getResourceAsStream("ko.js");
jaroslav@1493
    30
        if (is == null) {
jaroslav@1493
    31
            return "No resource found!";
jaroslav@1493
    32
        }
jaroslav@1493
    33
        byte[] arr = new byte[4092];
jaroslav@1493
    34
        int len = is.read(arr);
jaroslav@1493
    35
        if (len == -1) {
jaroslav@1493
    36
            return "No data read!";
jaroslav@1493
    37
        }
jaroslav@1493
    38
        return new String(arr, 0, len, "UTF-8");
jaroslav@114
    39
    }
jaroslav@114
    40
}