---
title: "Class.getResourceAsStream"
author: "OpenMind"
date: "2013-04-06T14:09:46Z"
tags: []
categories: ["编程语言"]
slug: "class-getresourceasstream"
draft: false
lastmod: "2013-04-06T14:09:46Z"
id: 1676744
url: "https://openmind.iteye.com/blog/1676744"
---

Class.getResourceAsStream("abc.properties")方法：
1，如果使用“/”开头则从类路径根目录寻找资源；
2，没有“/”开头，则选择相对路径，即当前class同包下面找；

ClassLoader.getResourceAsStream("abc.properties"):
1，不能用“/”开头，只能从根目录寻找。
2，根据不同ClassLoader实现也不一样。