OpenCores
URL https://opencores.org/ocsvn/usb_fpga_1_2/usb_fpga_1_2/trunk

Subversion Repositories usb_fpga_1_2

[/] [usb_fpga_1_2/] [trunk/] [java/] [ztex/] [JInputStream.java] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
/*!
2
   Java Driver API for the ZTEX Firmware Kit
3
   Copyright (C) 2008-2009 ZTEX e.K.
4
   http://www.ztex.de
5
 
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License version 3 as
8
   published by the Free Software Foundation.
9
 
10
   This program is distributed in the hope that it will be useful, but
11
   WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
   General Public License for more details.
14
 
15
   You should have received a copy of the GNU General Public License
16
   along with this program; if not, see http://www.gnu.org/licenses/.
17
!*/
18
 
19
/*
20
    creates an input stream from a file as system resource (i.e. from the current .jar file)
21
*/
22
package ztex;
23
 
24
import java.io.*;
25
import java.util.*;
26
import java.net.*;
27
 
28
public class JInputStream {
29
 
30
    static public InputStream getInputStream ( String fileName ) throws SecurityException, FileNotFoundException {
31
        InputStream is = null;
32
        try {
33
// Step 1: Normal way (i.e. from the current directory)
34
            is = new FileInputStream(fileName);
35
        }
36
        catch ( FileNotFoundException e ) {
37
// Step 2: As system ressource
38
            is = ClassLoader.getSystemResourceAsStream( fileName );
39
        }
40
        if ( is == null )
41
            throw new FileNotFoundException("File not found: "+fileName);
42
 
43
        return is;
44
    }
45
}
46
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.