/[classpath]/cp-tools/src/gnu/classpath/tools/Util.java
ViewVC logotype

Diff of /cp-tools/src/gnu/classpath/tools/Util.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by cbj, Wed Dec 18 00:16:51 2002 UTC revision 1.2 by cbj, Sun Jan 30 02:21:06 2005 UTC
# Line 1  Line 1 
1  /* gnu.classpath.tools.Util  /*
2     Copyright (C) 2001 Free Software Foundation, Inc.   * gnu.classpath.tools.Util Copyright (C) 2001 Free Software Foundation, Inc.
3     *
4  This file is part of GNU Classpath.   * This file is part of GNU Classpath.
5     *
6  GNU Classpath is free software; you can redistribute it and/or modify   * GNU Classpath is free software; you can redistribute it and/or modify it
7  it under the terms of the GNU General Public License as published by   * under the terms of the GNU General Public License as published by the Free
8  the Free Software Foundation; either version 2, or (at your option)   * Software Foundation; either version 2, or (at your option) any later version.
9  any later version.   *
10     * GNU Classpath is distributed in the hope that it will be useful, but WITHOUT
11  GNU Classpath is distributed in the hope that it will be useful, but   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  WITHOUT ANY WARRANTY; without even the implied warranty of   * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   * details.
14  General Public License for more details.   *
15     * You should have received a copy of the GNU General Public License along with
16  You should have received a copy of the GNU General Public License   * GNU Classpath; see the file COPYING. If not, write to the Free Software
17  along with GNU Classpath; see the file COPYING.  If not, write to the   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   */
 02111-1307 USA. */  
   
19  package gnu.classpath.tools;  package gnu.classpath.tools;
20    
21  import java.io.BufferedInputStream;  import java.io.BufferedInputStream;
# Line 33  import java.util.zip.ZipException; Line 31  import java.util.zip.ZipException;
31    
32  public class Util  public class Util
33  {  {
34    public static InputStream getInputStream (String filename, String classpath)    public static InputStream getInputStream(String filename, String classpath)
35    {    {
36      StringTokenizer st = new StringTokenizer (classpath, File.pathSeparator);      StringTokenizer st = new StringTokenizer(classpath, File.pathSeparator);
37      while (st.hasMoreTokens ())      while (st.hasMoreTokens())
38        {        {
39          String path = st.nextToken ();          String path = st.nextToken();
40          File f = new File (path);          File f = new File(path);
41          if (f.exists () && f.isDirectory ())          if (f.exists() && f.isDirectory())
42            {            {
43              f = new File (f, filename);              f = new File(f, filename);
44              if (f.exists ())              if (f.exists())
45                {                {
46                  try                  try
47                    {                    {
48                      FileInputStream fis = new FileInputStream (f);                      FileInputStream fis = new FileInputStream(f);
49                      return new BufferedInputStream (fis);                      return new BufferedInputStream(fis);
50                    }                    }
51                  catch (FileNotFoundException fe) { }                  catch (FileNotFoundException fe)
52                }                    {
53            }                        }
54          else                }
55            {            }
56              if (f.exists () && f.isFile ())          else
57                {            {
58                  try              if (f.exists() && f.isFile())
59                    {                {
60                      ZipFile zip = new ZipFile (f);                  try
61                      ZipEntry entry = zip.getEntry (filename);                    {
62                      if (entry != null)                      ZipFile zip = new ZipFile(f);
63                        return zip.getInputStream (entry);                      ZipEntry entry = zip.getEntry(filename);
64                    }                      if (entry != null)
65                  catch (IllegalStateException ise) { }                        return zip.getInputStream(entry);
66                  catch (ZipException ze) { }                    }
67                  catch (IOException ioe) { }                              catch (IllegalStateException ise)
68                }                    {
69            }                    }
70                    catch (ZipException ze)
71                      {
72                      }
73                    catch (IOException ioe)
74                      {
75                      }
76                  }
77              }
78        }        }
79      return null;      return null;
80    }    }
81  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26