- 浏览: 93953 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (61)
- Hibernate (5)
- WebService (6)
- Python (13)
- ExtJs (0)
- Java (20)
- SMB (1)
- Game (1)
- Java Advanced Image (1)
- CMD (4)
- Oracle (2)
- Windows (2)
- Linux (1)
- Forums (1)
- Struts (2)
- Internationalization (1)
- NTLM (1)
- HttpClient (1)
- Http (1)
- Form (1)
- Tomcat (2)
- Log4j (1)
- Eclipse (1)
- ant (1)
- soap (0)
- SSL (2)
- security (2)
- permission (1)
- 面试 (0)
- authentication (1)
- Spring (0)
- ioc (0)
- javascript (1)
- license (0)
- web (0)
- Maven (0)
- website (0)
- tool (0)
- git (1)
- Thread (2)
- 软件工程 (0)
- mongodb (1)
最新评论
-
howgoo:
OpenSystemArchitect 中文乱码。
免费的数据库建模工具 -
tojaoomy:
如果需要输出时不换行,在最后加上逗号即可。比如print 'H ...
Python静态属性,静态方法 -
tojaoomy:
http://www.oracle.com/technetwo ...
丢失更新 -
tojaoomy:
teasp 写道tojaoomy 写道teasp 写道toja ...
synchronized (this) 柳暗花明又一村 -
teasp:
tojaoomy 写道teasp 写道tojaoomy 写道t ...
synchronized (this) 柳暗花明又一村
import java.io.IOException; import java.net.MalformedURLException; import java.net.UnknownHostException; import jcifs.smb.SmbException; import jcifs.smb.SmbFile; import jcifs.smb.SmbFileInputStream; public class SMBTest { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try { SmbFile file = new SmbFile( "smb://administrator:password@ip/hejian/hello.txt"); SmbFileInputStream sfis = new SmbFileInputStream(file); byte b[] = new byte[2]; while (-1 != sfis.read(b)) { System.out.print(new String(b)); } sfis.close(); } 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 { } } }
假如公司有域认证的话,上面的方法就行不通了,不过还有另外一方法:
package com.rits.samplescan.smb; import java.io.IOException; import java.net.MalformedURLException; import java.net.UnknownHostException; import jcifs.smb.NtlmPasswordAuthentication; import jcifs.smb.SmbException; import jcifs.smb.SmbFile; import jcifs.smb.SmbFileInputStream; public class SMBTest { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String domain = "domain"; String username = "username"; String password = "password"; NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(domain,username,password); try { SmbFile file = new SmbFile( "smb://10.10.10.18/share/hello.txt" ,auth); SmbFileInputStream sfis = new SmbFileInputStream(file); byte b[] = new byte[2]; while (-1 != sfis.read(b)) { System.out.print(new String(b)); } sfis.close(); } 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 { } } }
- jcifs-1.3.17.jar (386.9 KB)
- 下载次数: 1
发表评论
-
Filter,Servlet,Conponent如何获取ApplicationContext
2014-08-04 18:35 1193Filter 获取Context 在init()方法获取S ... -
synchronized (this) 柳暗花明又一村
2013-05-17 16:23 1446今天写一个测试类,主要是测试wait(long timeo ... -
同一个线程synchronized方法调用synchronized方法
2013-02-21 16:28 884一个线程里面有两个synchronized方法a(),b( ... -
Java开源工具:网站开发工具清单
2012-07-23 14:07 0【IT168 技术】美国程序员Jon Sco ... -
Maven construct Maven Project
2012-07-17 17:36 0<project xmlns="http ... -
开源中最好的Web开发的资源
2012-06-20 09:52 0文章来源:Best “must know” open sour ... -
SimulateSpringIOC
2012-05-20 15:05 0Code View: package jp.co.ri ... -
User Authentication
2012-05-18 14:35 1743The Java Authentication and Aut ... -
Java SSL
2012-05-14 16:40 1086一直调查SSL的问题,毫无进展,头疼,先把手头搞定的资料整理 ... -
Security Managers and Permissions
2012-05-11 17:44 945Once a class has been loaded in ... -
[转]Web Services Over SSL - HOW TO
2012-05-07 15:31 879一篇好文章,原文地址:http://www.pankaj- ... -
Java Use the keyword goto
2012-05-07 14:53 0Today,I am unconsciously found ... -
HttpClient Access to HTML Form
2012-03-19 17:27 943Sample Html Form Code: <s:f ... -
Top 10 Java Developer Forums
2012-03-08 15:46 1083Developers get into tricky situ ... -
发几个收藏的Java游戏
2012-02-29 13:47 578JavaMine.jar 扫雷 jdiamonds. ... -
Axis2 integrate with tomcat occur "unsupport" error
2012-02-27 14:42 1838Creating a Dynamic web project ... -
PD(PowerDesigner) 导出的sql中去掉双引号
2012-02-20 23:21 0http://user.qzone.qq.com/714719 ... -
JAEE5.0工程JSTL不能正常使用解决办法
2012-02-21 18:21 892在Tomcat的安装路径下:apache-tomcat-7.0 ... -
通过六个题目彻底掌握String笔试面试题
2012-02-21 18:22 7051 public static void main( ... -
PowerDesigner(15.1.0.2805)反向工程错误解决汇总
2012-02-20 23:14 1267错误一:Non SQL Error : Could not ...
相关推荐
As we all know, We often need to share some files including such as documents, video,... All visits are under your surveillance, you can quickly stop any shared folder to prevent the unauthorized access.
Move to Applications folder demo 核心代码来自:https://github.com/RISCfuture/TMMoveToApplicationsFolder
How to display the Browse for Folder dialog
fail_to_use_service_name_to_access_share_folder_in_Win2008_cluster
add user and bind to login folder
Folder conversion: Entire folders of C# code files are converted to Java code files.(文件夹转换) 2. Code snippet and file conversion: Our snippet conversion accuracy is outstanding and does not ...
安装提示folder depth is too large to run the setup
本程序用于解决CV6.0 与office2007冲突导致的无法添加文件的问题
VC folder tree access
java_folder:核心java编程
win7 office2007 删除Groove Folder Synchronization菜单项 http://hi.baidu.com/fei126222/blog/item/dde559dc439ae2adcc11661b.html
Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder! 问题的缺失文件 eclipse.buildId=M20100211-1343 java.version=1.6.0_10-rc2 java.vendor=Sun Microsystems Inc. ...
java PDFToImageConverter path_to_pdf_file.pdf path_to_output_folder 请将path_to_pdf_file.pdf替换为您要转换的PDF文件的路径,将path_to_output_folder替换为输出图像的文件夹路径。 脚本将使用Apache PDFBox库...
Instructions on how to download and install the JavaMail API are contained in the course. In addition, you will need a development environment such as the JDK 1.1.6+ or the Java 2 Platform, Standard...
java-folder
This sample shows how to create, read, write, copy and delete a file, how to retrieve file properties, and how to track a file or folder so that your app can access it again. This sample uses Windows....
一键去除视频和图片水印
Test Folder Size 2.1 Folder Size 2.1
HOW TO USE DJ JAVA DECOMPILER: To decompile a single JAVA class file you can: 1.Select Open and load your desired class file. 2.Double-click the CLASS file you want to decompile. 3.Drag-and-drop ...
This tutorial will show you how to access the information you need in your browser by simply highlighting your text in the edit window and clicking your toolbar button How to install UE3 UE3 is the ...