ファイルをプリンタに直接送信して印刷するために、この小さな Java プログラムを作成しました。
public static void main(String args[]) throws IOException
{
try{
InputStream in= new FileInputStream(new File("C:\\example.txt"));
OutputStream out=new FileOutputStream(new File("\\\\path\\printer\\example.txt"));
// Transfer bytes from in to out
byte[] buf=new byte[1024];
int len;
while ((len=in.read(buf)) > 0) {
out.write(buf,0,len);
}
in.close();
out.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
これは Windows では正常に機能しますが、Mac では機能しません。
Mac Os Xで同じことを行うにはどうすればよいですか?
Macマシンでローカルにあるフォルダーから別のフォルダーにファイルをコピーしようとしたが、FileOutputStreamがリモートフォルダーを取得したときは機能しないことに注意してください。