클래스 패스 및 파일 확인하는 코드
boolean fileExists = false;
String[] classPathArray = null;
try {
classPathArray = System.getProperty("java.class.path").split(";");
File file = null;
String dirPath = null;
for(int i=0; i < classPathArray.length; i++)
{
file = new java.io.File(classPathArray[i]);
dirPath = file.getCanonicalFile().getParent();
if(dirPath.indexOf("\\") != -1)
dirPath = dirPath.replace("\\", "/");
if(!dirPath.endsWith("/"))
dirPath = dirPath + "/";
file = new File(dirPath + fileName);
fileExists = file.exists();
if(fileExists) {
this.fullFilePath = dirPath + fileName;
break;
}
}
} catch(IOException e) {
// e.printStackTrace();
}
'Java' 카테고리의 다른 글
| Object 재사용 (0) | 2008/06/16 |
|---|---|
| Avoiding Garbage Collection (0) | 2008/06/16 |
| 클래스 패스 및 파일 확인하는 코드 (0) | 2008/06/16 |
| 파일에 락 걸기.. (0) | 2008/06/13 |
| Convert interchangeably between a ByteBuffer and a byte array (0) | 2008/06/13 |