Popular Posts
DNS SERVER LIST Google 8.8.8.8 8.8.4.4 TWNIC 192.83.166.11 211.72.210.250 HiNet 168.95.1.1 168.95.192.1 Seednet 北區 DNS (台北, 桃園, 新竹, 宜蘭, 花蓮, 苗栗) 139.... write 語法: write at [/][<pos>][(<len>)] output 用法: write 'Bruce'. " 輸出常數 Bruce data CNAME(10) value... Regex (Regular Expression) tool Eclipse Regular Expression Tester Java正規表示式工具-Eclipse GUI介面 [Visual Studio 2010] 好用的 Regex 輔助工具
Blog Archive
Stats
File operation at SMB / UNC (network neighborhood)
import java.io.IOException;
import java.io.OutputStreamWriter;

import jcifs.Config;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileOutputStream;

public class Program {

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub

        StringBuilder sb = new StringBuilder("<html><head><title>9 x 9</title></head><body><table border='1'>");
        sb.append(System.getProperty("line.separator"));
        for (int i = 1; i < 10; i++) {
            sb.append("<tr>");
            for (int j = 1; j < 10; j++) {
                sb.append(String.format("<td>%d x %d = %d</td>", i, j, i * j));
            }
            sb.append("</tr>");
            sb.append(System.getProperty("line.separator"));
        }
        sb.append("</table></body></html>");

        Config.setProperty("jcifs.smb.client.domain", "mydomain");
        Config.setProperty("jcifs.smb.client.username", "bruce");
        Config.setProperty("jcifs.smb.client.password", "12345678");

        SmbFile remotePath = new SmbFile("file://computer_name/mis/subfolder/test.html");
        // SmbFile remotePath = new SmbFile("smb://hostname/upload$/test.html");

        SmbFileOutputStream sfos = new SmbFileOutputStream(remotePath);
        OutputStreamWriter osw = new OutputStreamWriter(sfos);
        osw.write(sb.toString());
        osw.close();
        sfos.close();
    }

}
Library : http://jcifs.samba.org/