读取共享文档的文件,用 JCIFS jar包
package test;
import java.sql.ResultSet;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import jcifs.smb.SmbFile;
public class ModifySuffixName {
public static void main(String[] args) throws IOException {
Connection con = null;// 创建一个数据库连接
try {
Class.forName("oracle.jdbc.driver.OracleDriver");// 加载Oracle驱动程序
String url = "jdbc:oracle:thin:@**.**.*.2*:1521:***";// 127.0.0.1是本机地址,XE是精简版Oracle的默认数据库名
String user = "***";// 用户名,系统默认的账户名
String password = "**";// 你安装时选设置的密码
con = DriverManager.getConnection(url, user, password);// 获取连接
String sql = "select";
//创建远程文件对象
String remotePhotoUrl = "smb://username:password@192.168.6.**/oldOsFile/2016file/";
//SmbFile JCIFS jar包
SmbFile remoteFile = new SmbFile(remotePhotoUrl);
remoteFile.connect(); //尝试连接
SmbFile[] fileNameMap = remoteFile.listFiles();
PreparedStatement pre = null;// 创建预编译语句对象,一般都是用这个而不用Statement
for(int i = 0, j = fileNameMap.length; i < j; i++) {
pre = con.prepareStatement(sql);// 实例化预编译语句
pre.setString(1, fileNameMap[i].getName());
ResultSet rs = pre.executeQuery();
String newFileName= "";
String suffix = "";
while(rs.next()) {
newFileName = rs.getString("dawjid");
suffix = rs.getString("suffix");
System.out.println(newFileName + "." + suffix);
fileNameMap[i].renameTo(new SmbFile(remotePhotoUrl + newFileName + '.' + suffix));
};
if(pre != null) {
pre.close();
};
};
}catch(Exception e) {
// TODO: handle exception
e.printStackTrace();
};
}
};