Here you can find the source of getInputStream(Class> ownerClass, String subName, String extension)
Parameter | Description |
---|---|
ownerClass | the owner class |
subName | the resource sub-name, or null to open the resource that is named like the class |
extension | the file name extension |
public static InputStream getInputStream(Class<?> ownerClass, String subName, String extension)
//package com.java2s; /**//www .j ava 2 s . com * Copyright (c) 2011 Martin Geisse * * This file is distributed under the terms of the MIT license. */ import java.io.InputStream; public class Main { /** * Opens an {@link InputStream} for a class-associated resource. * @param ownerClass the owner class * @param subName the resource sub-name, or null to open the * resource that is named like the class * @param extension the file name extension * @return the input stream */ public static InputStream getInputStream(Class<?> ownerClass, String subName, String extension) { String localName; if (subName == null) { localName = ownerClass.getSimpleName() + '.' + extension; } else { localName = ownerClass.getSimpleName() + '_' + subName + '.' + extension; } return ownerClass.getResourceAsStream(localName); } }