흑흑… 개삽질의 연속이었다.. 영우와 내가 미친듯이 검색한 결과.. 운좋게 jcifs 라이브러리가 내눈앞에 나타났다… 오오 신과같은 존재아.. 백번 말해봤자 소용없다 일단 소스코드 고고~
import java.util.Enumeration;
import java.util.Hashtable;
import jcifs.smb.SmbFile;
public class test5 {
public static void main(String[] args) throws Exception {
SmbFile root = new SmbFile("smb://도메인");
Hashtable printerHash = new Hashtable();
searchForPrinters(root, printerHash);
Enumeration keys = printerHash.keys();
System.out.println("Number of Printers Found: " + printerHash.size());
SmbFile file = null;
while (keys.hasMoreElements()) {
file = ((SmbFile)keys.nextElement());
System.out.println("UNC: " + file.getUncPath());
}
}
private static void searchForPrinters(SmbFile root, Hashtable printers) throws Exception {
SmbFile[] kids= null;
try {
kids = root.listFiles();
} catch (Exception e) {
}
if (kids == null)
return;
for (int i = 0; i < kids.length; i++) {
if (kids[i].getType() == SmbFile.TYPE_WORKGROUP || kids[i].getType() == SmbFile.TYPE_SERVER)
searchForPrinters(kids[i], printers);
else if (kids[i].getType() == SmbFile.TYPE_PRINTER) {
printers.put(kids[i], Boolean.TRUE);
}
}
}
}
간단한 예제 코드이다. 후.. 결국 해당 도메인에 접근해서 그 도메인에 물려있는 프린터 목록(물론 네트워크 공유되어있는 프린터다)을 가져온다.. 후후..
우리나라 사이트엔 좀처럼 사용한 사람을 보지 못해서 해외사이트 정독했다..
이러다 영어 늘겠어-_-..
암튼 멋진 경험이었어..-_-...
'IT > JAVA' 카테고리의 다른 글
1.WEB-INF/lib 에 위치할 jar파일 (0) | 2010.06.07 |
---|---|
스프링 정의할때 xml 스키마 모음 (0) | 2009.12.28 |
Java Web 개발자들을 위한 학습 로드맵 (0) | 2009.12.22 |
Java 도움되는 사이트(Site) 목록 (0) | 2009.12.21 |
Velocity error (0) | 2009.12.17 |