我正在编写一个访问网络打印机的应用程序.作为该应用程序的一部分,我需要知道打印机的"状态".打印机通告其状态的唯一方法是通过SNMP.Java本身没有任何说SNMP协议的工具,所以我不知道该怎么做.如何从Java应用程序访问打印机的SNMP状态更新?
我需要使用Java将一些文本写入PDF文档.我写了一个代码.但是我无法打开文件.如果你们有一些想法请与我分享.
public class WritPDF
{
public static void main(String[] args)
{
Writer writer = null;
try
{
String text = "This is a text file";
File file = new File("C:/Users/PrinterTest/Hi1.pdf");
writer = new BufferedWriter(new FileWriter(file));;
writer.write(text);
} catch (FileNotFoundException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
} finally
{
try
{
if (writer != null)
{
}
} catch (IOException e)
{}
}
}
}
Run Code Online (Sandbox Code Playgroud)