private static void writeRemoteFile(String file, StringBuilder message) throws IOException {
//file example(without user and password):[ smb://ip/sharefolder/(例如:smb://127.0.0.1/BMS_FILE/import/)]
//file example(with user and password):[ Smb://username:password@ip/sharefolder/(例如:smb://amd:123456@127.0.0.1/BMS_FILE/import/)]
SmbFile smbFile = null;
SmbFileOutputStream out = null;
try {
smbFile = new SmbFile(file);
out = new SmbFileOutputStream(smbFile, true); //建立smb文件输入流
out.write(message.toString().getBytes("utf-8"));
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SmbException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if(out != null) {
out.flush();
out.close();
}
}
}