使用java,减去异常处理,就像

一样简单
FileOutputStream ostream = new FileOutputStream("\\\\host\\share");
PrintStream printStream = new PrintStream(ostream);
printStream.print("HELLO PRINTER");
printStream.close();
ostream.close();
有帮助吗?

解决方案

File.open("\\\\host\\share") do |f|
  f.print("HELLO PRINTER#{12.chr}")
end

其他提示

虽然我从来没有尝试过从Ruby打印,虽然我没有可用于测试的Windows机器,但在我看来你不想使用文件类,而是 IO 类。您可以在此处查看其文档: http://ruby-doc.org/core/classes /IO.html 。看起来它实际上有Windows特定的选项,所以看看它是否有用,请告诉我原因。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top