2011-02-09 7 views
0

PrintServiceクラスを使用して現在接続されているプリンタの詳細を取得していますが、接続されたプリンタのIPを取得する必要があります。ip informatを取得する必要があります

添付されているすべてのプリンタの名前を取得できましたが、IPを取得できませんでした。

PrintService[] printServices = 
    PrintServiceLookup.lookupPrintServices(null, null); 
System.out.println("Number of print services: " + printServices.length); 

for (PrintService printer : printServices) 
    //System.out.println("Printer: " + printer.getName()); 
    System.out.println("Printer: " + printer.getName()); 
} 

私はプリンタのIPをどのように取得できますか?

答えて

0

InetAddress.getByNameを試してください。私は、この場合のプリンタ名が実際には真のネットワーク/ DNS名であることを確かめることはできませんが、そうであれば、必要なものが得られます。

String ip = InetAddress.getByName(printer.getName()).toString() 
+0

これは動作しません。プリンタがホスト名で設定されていません...それ以外の方法はありますか? printserviceクラスの使用?? – user609745

関連する問題