---
title: "Java读取classpath中的文件"
author: "leonmau"
date: "2011-08-29T11:06:36Z"
tags: []
categories: ["编程语言"]
slug: "java-classpath"
draft: false
lastmod: "2011-08-29T11:06:36Z"
id: 1160175
url: "https://leonmau.iteye.com/blog/1160175"
---

```
/**
 * 类AppsImport.java的实现描述：TODO 类实现描述
 * 
 * @author liangliang.maoll 2011-8-29 上午10:33:06
 */
public class AppsImport {

    private static final BranchService BRANCH_SERVICE = MinasServiceLocator.getBranchService();
    private static final String        token          = TokenService.getToken();
    private static final String        REPO_INTL      = "intl";

    public static void main(String[] args) {
        InputStream in = ClassLoader.getSystemResourceAsStream("app_name.txt");
        BufferedReader bufferReader = new BufferedReader(new InputStreamReader(in));

        String tempString = null;
        try {
            tempString = bufferReader.readLine();
            String[] appNames = tempString.split(",");
            for (int i = 0; i < appNames.length; i++) {
                appNames[i] = appNames[i].substring(1, appNames[i].length() - 2);
            }
            bufferReader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
```