加载内部指定资源
<p>Function: getResourceAsReader</p>
<p>Description: </p>

@param resource
@return
@author acexy@thankjava.com
@date 2016年3月9日 下午5:06:34
@version 1.0
504318
public static Reader getResourceAsReader(String resource) {
        InputStream in = classLoaderWrapper.getResourceAsStream(resource);
        if (in == null) {
            return null;
        }
        return new InputStreamReader(in);
    }
175723
public static Resource newSystemResource(String resource)
        throws IOException
    {
        URL url=null;
        // Try to format as a URL?
        ClassLoader
            loader=Thread.currentThread().getContextClassLoader();
        if (loader!=null)
        {
            url=loader.getResource(resource);
            if (url==null && resource.startsWith("/"))
                url=loader.getResource(resource.substring(1));
        }
        if (url==null)
        {
            loader=Resource.class.getClassLoader();
            if (loader!=null)
            {
                url=loader.getResource(resource);
                if (url==null && resource.startsWith("/"))
                    url=loader.getResource(resource.substring(1));
            }
        }
        
        if (url==null)
        {
            url=ClassLoader.getSystemResource(resource);
            if (url==null && resource.startsWith("/"))
                url=loader.getResource(resource.substring(1));
        }
        
        if (url==null)
            return null;
        
        return newResource(url);
    }
666140
@Override
	public Reader getResourceBundleReader(String bundleName) throws ResourceNotFoundException {

		ReadableByteChannel inchannel = getResourceBundleChannel(bundleName, false);
		return Channels.newReader(inchannel, charset.newDecoder(), -1);
	}
837386
private CmsResource readResource(String resourceName) throws CmsException {

        CmsResource resource = null;
        try {
            resource = getCms().readResource(resourceName, CmsResourceFilter.ALL);
        } catch (CmsVfsResourceNotFoundException e) {
            throw new CmsVfsResourceNotFoundException(
                Messages.get().container(
                    Messages.ERR_RESOURCE_DOES_NOT_EXIST_3,
                    resourceName,
                    getCms().getRequestContext().getCurrentProject().getName(),
                    getCms().getRequestContext().getSiteRoot()),
                e);
        }
        return resource;
    }
716981
private void readResource(Document.Resources.Resource resource)
   {
      Resource mpxjResource = m_projectFile.addResource();
      mpxjResource.setName(resource.getName());
      mpxjResource.setResourceCalendar(m_calendarMap.get(resource.getCalendarID()));
      mpxjResource.setStandardRate(new Rate(resource.getCost(), resource.getCostTimeUnit()));
      mpxjResource.setEmailAddress(resource.getEMail());
      mpxjResource.setGroup(resource.getGroup());
      //resource.getHyperlinks()
      mpxjResource.setUniqueID(resource.getID());
      //resource.getMarkerID()
      mpxjResource.setNotes(resource.getNote());
      mpxjResource.setID(Integer.valueOf(resource.getOutlineNumber()));
      //resource.getStyleProject()
      mpxjResource.setType(resource.getSubType() == null ? resource.getType() : resource.getSubType());
   }
298681
public I_CmsResourceLoader getLoader(CmsResource resource) throws CmsLoaderException {

        return getLoader(getResourceType(resource.getTypeId()).getLoaderId());
    }
803937
public static ResourceHandle use(Resource resource) {
        return resource instanceof ResourceHandle
                ? ((ResourceHandle) resource) : new ResourceHandle(resource);
    }
846928
public List<ReconfigBeanDefinitionHolder> load(Resource resource) {
    List<ReconfigBeanDefinitionHolder> holders = new ArrayList<ReconfigBeanDefinitionHolder>();
    try {
      InputStream inputStream = resource.getInputStream();
      try {
        InputSource inputSource = new InputSource(inputStream);
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = factory.newDocumentBuilder();
        Document doc = docBuilder.parse(inputSource);
        Element root = doc.getDocumentElement();
        NodeList nl = root.getChildNodes();
        BeanDefinitionParser parser = new BeanDefinitionParser();
        for (int i = 0; i < nl.getLength(); i++) {
          Node node = nl.item(i);
          if (node instanceof Element) {
            Element ele = (Element) node;
            ReconfigBeanDefinitionHolder holder = parser.parseBeanDefinitionElement(ele);
            holders.add(holder);
          }
        }
      } finally {
        if (null != inputStream) {
          inputStream.close();
        }
      }
    } catch (Exception ex) {
      throw new RuntimeException("IOException parsing XML document from " + resource.getDescription(), ex);
    }
    return holders;
  }
729967
@Override
	public Reader getResourceAsReader(String resourceName) throws IOException {

		try {
			return rsHandler.getResource(null, resourceName, true);
		} catch (ResourceNotFoundException e) {
			throw new IOException("The resource '" + resourceName + "' was not found.");
		}
	}
1317377
@Override
	public Reader getResource(JoinableResourceBundle bundle, String resourceName, boolean processingBundle) {

		Reader rd = null;
		if (!resourceName.contains(":")) {
			InputStream is = context.getResourceAsStream(resourceName);
			if (is != null) {
				rd = new InputStreamReader(is, charset);
			}
		}
		return rd;
	}
689619
public ResourceMetaData getResourceMetaData(Resource resource)
    {
        Object o=resource.getAssociate();
        if (o instanceof ResourceMetaData)
            return (ResourceMetaData)o;
        return new ResourceMetaData(resource);
    }
1094261
public static String readResourceToString(@NotNull Class<?> clazz, @NotNull String resource) {
        try {
            try (Reader r = new BufferedReader(new InputStreamReader(clazz.getResourceAsStream(resource), "UTF-8"))) {

                Writer writer = new StringWriter();

                char[] buffer = new char[1024];
                int n;
                while ((n = r.read(buffer)) != -1) {
                    writer.write(buffer, 0, n);
                }

                return writer.toString();
            }
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
    }
454132
public static Resource prepareClasspathResourceIfNeeded(final Resource resource) {
        if (resource == null) {
            LOGGER.debug("No resource defined to prepare. Returning null");
            return null;
        }
        return prepareClasspathResourceIfNeeded(resource, false, resource.getFilename());
    }
925136
protected void addResourceHttpHeaders(final FedoraResource resource) {
        if (resource instanceof FedoraBinary) {
            final FedoraBinary binary = (FedoraBinary)resource;
            final Date createdDate = binary.getCreatedDate() != null ? Date.from(binary.getCreatedDate()) : null;
            final Date modDate = binary.getLastModifiedDate() != null ? Date.from(binary.getLastModifiedDate()) : null;

            final ContentDisposition contentDisposition = ContentDisposition.type("attachment")
                    .fileName(binary.getFilename())
                    .creationDate(createdDate)
                    .modificationDate(modDate)
                    .size(binary.getContentSize())
                    .build();

            servletResponse.addHeader(CONTENT_TYPE, binary.getMimeType());
            // Returning content-length > 0 causes the client to wait for additional data before following the redirect.
            if (!binary.isRedirect()) {
                servletResponse.addHeader(CONTENT_LENGTH, String.valueOf(binary.getContentSize()));
            }
            servletResponse.addHeader("Accept-Ranges", "bytes");
            servletResponse.addHeader(CONTENT_DISPOSITION, contentDisposition.toString());
        }

        servletResponse.addHeader(LINK, "<" + LDP_NAMESPACE + "Resource>;rel=\"type\"");

        if (resource instanceof FedoraBinary) {
            servletResponse.addHeader(LINK, "<" + LDP_NAMESPACE + "NonRDFSource>;rel=\"type\"");
        } else if (resource instanceof Container || resource instanceof FedoraTimeMap) {
            servletResponse.addHeader(LINK, "<" + CONTAINER.getURI() + ">;rel=\"type\"");
            servletResponse.addHeader(LINK, buildLink(RDF_SOURCE.getURI(), "type"));
            if (resource.hasType(LDP_BASIC_CONTAINER)) {
                servletResponse.addHeader(LINK, "<" + BASIC_CONTAINER.getURI() + ">;rel=\"type\"");
            } else if (resource.hasType(LDP_DIRECT_CONTAINER)) {
                servletResponse.addHeader(LINK, "<" + DIRECT_CONTAINER.getURI() + ">;rel=\"type\"");
            } else if (resource.hasType(LDP_INDIRECT_CONTAINER)) {
                servletResponse.addHeader(LINK, "<" + INDIRECT_CONTAINER.getURI() + ">;rel=\"type\"");
            } else {
                servletResponse.addHeader(LINK, "<" + BASIC_CONTAINER.getURI() + ">;rel=\"type\"");
            }
        } else {
            servletResponse.addHeader(LINK, buildLink(RDF_SOURCE.getURI(), "type"));
        }
        if (httpHeaderInject != null) {
            httpHeaderInject.addHttpHeaderToResponseStream(servletResponse, uriInfo, resource);
        }

        addLinkAndOptionsHttpHeaders(resource);
        addAclHeader(resource);
        addMementoHeaders(resource);
    }
210849
public static X509Certificate readCertificate(final Resource resource) {
        try (val in = resource.getInputStream()) {
            return CertUtil.readCertificate(in);
        } catch (final Exception e) {
            throw new IllegalArgumentException("Error reading certificate " + resource, e);
        }
    }
709653
public static InputStream getResourceAsStream(String resource) {
        InputStream in = ClassUtils.getContextClassLoader().getResourceAsStream(resource);
        if (in == null) {
            in = IOUtils.class.getResourceAsStream(resource);
        }

        return in;
    }
877457
@Override
	public void addResourceReader(ResourceReader rd) {

		if (rd instanceof TextResourceReader) {
			resourceReaders.add((TextResourceReader) rd);
			Collections.sort(resourceReaders, new ResourceReaderComparator(config));
		}

		if (rd instanceof StreamResourceReader) {
			streamResourceReaders.add((StreamResourceReader) rd);
			Collections.sort(streamResourceReaders, new ResourceReaderComparator(config));
		}

		initReader(rd);
	}