Here you can find the source of getResourceAsStream(String path)
Parameter | Description |
---|---|
path | the resource to find. |
Parameter | Description |
---|---|
IOException | if unable to open the InputStream. |
public static InputStream getResourceAsStream(String path) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2006-2010 eBay Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 *******************************************************************************/ import java.io.IOException; import java.io.InputStream; public class Main { /**// w w w . j a va2 s. co m * Return the InputStream of the resource provided, following the {@link #findResource(String)} rules. * * @param path * the resource to find. * @return the {@link InputStream} to the resource, or null if not found. * @throws IOException * if unable to open the {@link InputStream}. * @see {@link URL#openStream()} */ public static InputStream getResourceAsStream(String path) throws IOException { ClassLoader cl = Thread.currentThread().getContextClassLoader(); return cl.getResourceAsStream(path); } }