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

Subversion Repositories usb_fpga_1_11

[/] [usb_fpga_1_11/] [trunk/] [java/] [ztex/] [JInputStream.java] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
/*!
2 9 ZTEX
   Java host software API of ZTEX SDK
3
   Copyright (C) 2009-2014 ZTEX GmbH.
4 2 ZTEX
   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
package ztex;
20
 
21
import java.io.*;
22
import java.util.*;
23
import java.net.*;
24
 
25
/** * Creates an input stream from a regular file or a system resource file (i.e. a file from the current jar file). */
26
public class JInputStream {
27
 
28
/**
29
  * Constructs an instance from a giving file name.
30
  * @param fileName The file name.
31
  * @throws SecurityException Signals a security violation.
32
  * @throws FileNotFoundException Thrown if the file was not found.
33
  */
34
    static public InputStream getInputStream ( String fileName ) throws SecurityException, FileNotFoundException {
35
        InputStream is = null;
36
        try {
37
// Step 1: Normal way (i.e. from the current directory)
38
            is = new FileInputStream(fileName);
39
        }
40
        catch ( FileNotFoundException e ) {
41
// Step 2: As system ressource
42
            is = ClassLoader.getSystemResourceAsStream( fileName );
43
        }
44
        if ( is == null )
45
            throw new FileNotFoundException("File not found: "+fileName);
46
 
47
        return is;
48
    }
49
}
50
 

powered by: WebSVN 2.1.0

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