339 in.close();
340 }
341 return b;
342 }
343
344 // Object for synchronization around getResourceAsStream()
345 private Object syncResourceAsStream = new Object();
346 private Object syncResourceAsStreamFromJar = new Object();
347
348 // Flag to indicate getResourceAsStream() is in call
349 private boolean resourceAsStreamInCall = false;
350 private boolean resourceAsStreamFromJarInCall = false;
351
352 /**
353 * Returns an input stream for reading the specified resource.
354 *
355 * The search order is described in the documentation for {@link
356 * #getResource(String)}.<p>
357 *
358 * @param name the resource name
359 * @return an input stream for reading the resource, or <code>null</code>
360 * if the resource could not be found
361 * @since 1.1
362 */
363 public InputStream getResourceAsStream(String name)
364 {
365
366 if (name == null) {
367 throw new NullPointerException("name");
368 }
369
370 try
371 {
372 InputStream is = null;
373
374 // Fixed #4507227: Slow performance to load
375 // class and resources. [stanleyh]
376 //
377 // The following is used to avoid calling
378 // AppletClassLoader.findResource() in
379 // super.getResourceAsStream(). Otherwise,
399 is = url.openStream();
400 }
401
402 return is;
403 }
404 catch (Exception e)
405 {
406 return null;
407 }
408 }
409
410
411 /**
412 * Returns an input stream for reading the specified resource from the
413 * the loaded jar files.
414 *
415 * The search order is described in the documentation for {@link
416 * #getResource(String)}.<p>
417 *
418 * @param name the resource name
419 * @return an input stream for reading the resource, or <code>null</code>
420 * if the resource could not be found
421 * @since 1.1
422 */
423 public InputStream getResourceAsStreamFromJar(String name) {
424
425 if (name == null) {
426 throw new NullPointerException("name");
427 }
428
429 try {
430 InputStream is = null;
431 synchronized(syncResourceAsStreamFromJar) {
432 resourceAsStreamFromJarInCall = true;
433 // Call super class
434 is = super.getResourceAsStream(name);
435 resourceAsStreamFromJarInCall = false;
436 }
437
438 return is;
439 } catch (Exception e) {
|
339 in.close();
340 }
341 return b;
342 }
343
344 // Object for synchronization around getResourceAsStream()
345 private Object syncResourceAsStream = new Object();
346 private Object syncResourceAsStreamFromJar = new Object();
347
348 // Flag to indicate getResourceAsStream() is in call
349 private boolean resourceAsStreamInCall = false;
350 private boolean resourceAsStreamFromJarInCall = false;
351
352 /**
353 * Returns an input stream for reading the specified resource.
354 *
355 * The search order is described in the documentation for {@link
356 * #getResource(String)}.<p>
357 *
358 * @param name the resource name
359 * @return an input stream for reading the resource, or {@code null}
360 * if the resource could not be found
361 * @since 1.1
362 */
363 public InputStream getResourceAsStream(String name)
364 {
365
366 if (name == null) {
367 throw new NullPointerException("name");
368 }
369
370 try
371 {
372 InputStream is = null;
373
374 // Fixed #4507227: Slow performance to load
375 // class and resources. [stanleyh]
376 //
377 // The following is used to avoid calling
378 // AppletClassLoader.findResource() in
379 // super.getResourceAsStream(). Otherwise,
399 is = url.openStream();
400 }
401
402 return is;
403 }
404 catch (Exception e)
405 {
406 return null;
407 }
408 }
409
410
411 /**
412 * Returns an input stream for reading the specified resource from the
413 * the loaded jar files.
414 *
415 * The search order is described in the documentation for {@link
416 * #getResource(String)}.<p>
417 *
418 * @param name the resource name
419 * @return an input stream for reading the resource, or {@code null}
420 * if the resource could not be found
421 * @since 1.1
422 */
423 public InputStream getResourceAsStreamFromJar(String name) {
424
425 if (name == null) {
426 throw new NullPointerException("name");
427 }
428
429 try {
430 InputStream is = null;
431 synchronized(syncResourceAsStreamFromJar) {
432 resourceAsStreamFromJarInCall = true;
433 // Call super class
434 is = super.getResourceAsStream(name);
435 resourceAsStreamFromJarInCall = false;
436 }
437
438 return is;
439 } catch (Exception e) {
|