1、sun.net
import sun.net.ftp.*;
import sun.net.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.StringTokenizer;
/**
FTP 远程命令列表<br>
USER PORT RETR ALLO DELE SITE XMKD CDUP FEAT<br>
PASS PASV STOR REST CWD STAT RMD XCUP OPTS<br>
ACCT TYPE APPE RNFR XCWD HELP XRMD STOU AUTH<br>
REIN STRU SMNT RNTO LIST NOOP PWD SIZE PBSZ<br>
QUIT MODE SYST ABOR NLST MKD XPWD MDTM PROT<br>
在服务器上执行命令,如果用 sendServer 来执行远程命令(不能执行本地 FTP 命令)的话,所
有 FTP 命令都要加上\r\n<br>
ftpclient.sendServer("XMKD /test/bb\r\n"); //执行服务器上的 FTP 命令<br>
ftpclient.readServerResponse 一定要在 sendServer 后调用<br>
nameList("/test")获取指目录下的文件列表<br>
XMKD建立目录,当目录存在的情况下再次创建目录时报错<br> XRMD 删除目录<br>
DELE 删除文件<br>
* <p>Title: 使用 JAVA 操作 FTP 服务器(FTP 客户端)</p>
* <p>Description: 上传文件的类型及文件大小都放到调用此类的方法中去检测,比如放到前台
JAVASCRIPT中去检测等
* 针对 FTP 中的所有调用使用到文件名的地方请使用完整的路径名(绝对路径开始)。
* </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: 静靖工作室</p>
* @author 欧朝敬 13873195792
* @version 1.0
*/
public class FtpUpfile {
private FtpClient ftpclient;
private String ipAddress;
private int ipPort;
private String userName;
private String PassWord;
/**
* 构造函数
* @param ip String 机器 IP
* @param port String 机器 FTP 端口号 * @param username String FTP 用户名
* @param password String FTP 密码
* @throws Exception
*/
public FtpUpfile(String ip, int port, String username, String password) throws
Exception {
ipAddress = new String(ip);
ipPort = port;
ftpclient = new FtpClient(ipAddress, ipPort);
//ftpclient = new FtpClient(ipAddress);
userName = new String(username);
PassWord = new String(password);
}
/**
* 构造函数
* @param ip String 机器 IP,默认端口为 21
* @param username String FTP 用户名
* @param password String FTP 密码
* @throws Exception
*/
public FtpUpfile(String ip, String username, String password) throws
Exception { ipAddress = new String(ip);
ipPort = 21;
ftpclient = new FtpClient(ipAddress, ipPort);
//ftpclient = new FtpClient(ipAddress);
userName = new String(username);
PassWord = new String(password);
}
/**
* 登录 FTP 服务器
* @throws Exception
*/
public void login() throws Exception {
ftpclient.login(userName, PassWord);
}
/**
* 退出 FTP 服务器
* @throws Exception
*/
public void logout() throws Exception {
//用 ftpclient.closeServer()断开 FTP 出错时用下更语句退出 ftpclient.sendServer("QUIT\r\n");
int reply = ftpclient.readServerResponse(); //取得服务器的返回信息
}
/**
* 在FTP服务器上建立指定的目录,当目录已经存在的情下不会影响目录下的文件,这样用以
判断 FTP
* 上传文件时保证目录的存在目录格式必须以"/"根目录开头
* @param pathList String
* @throws Exception
*/
public void buildList(String pathList) throws Exception {
ftpclient.ascii();
StringTokenizer s = new StringTokenizer(pathList, "/"); //sign
int count = s.countTokens();
String pathName = "";
while (s.hasMoreElements()) {
pathName = pathName + "/" + (String) s.nextElement();
try {
ftpclient.sendServer("XMKD " + pathName + "\r\n");
} catch (Exception e) {
e = null;
} int reply = ftpclient.readServerResponse();
}
ftpclient.binary();
}
/**
* 取得指定目录下的所有文件名,不包括目录名称
* 分析 nameList 得到的输入流中的数,得到指定目录下的所有文件名
* @param fullPath String
* @return ArrayList
* @throws Exception
*/
public ArrayList fileNames(String fullPath) throws Exception {
ftpclient.ascii(); //注意,使用字符模式
TelnetInputStream list = ftpclient.nameList(fullPath);
byte[] names = new byte[2048];
int bufsize = 0;
bufsize = list.read(names, 0, names.length); //从流中读取
list.close();
ArrayList namesList = new ArrayList();
int i = 0;
int j = 0;
while (i < bufsize /*names.length*/) { //char bc = (char) names;
//System.out.println(i + " " + bc + " : " + (int) names);
//i = i + 1;
if (names[i] == 10) { //字符模式为 10,二进制模式为 13
//文件名在数据中开始下标为j,i-j为文件名的长度,文件名在数据中的结束下标为i-1
//System.out.write(names, j, i - j);
//System.out.println(j + " " + i + " " + (i - j));
String tempName = new String(names, j, i - j);
namesList.add(tempName);
//System.out.println(temp);
// 处理代码处
//j = i + 2; //上一次位置二进制模式
j = i + 1; //上一次位置字符模式
}
i = i + 1;
}
return namesList;
}
/**
* 上传文件到 FTP 服务器,destination 路径以 FTP 服务器的"/"开始,带文件名、
* 上传文件只能使用二进制模式,当文件存在时再次上传则会覆盖
* @param source String * @param destination String
* @throws Exception
*/
public void upFile(String source, String destination) throws Exception {
buildList(destination.substring(0, destination.lastIndexOf("/")));
ftpclient.binary(); //此行代码必须放在 buildList 之后
TelnetOutputStream ftpOut = ftpclient.put(destination);
TelnetInputStream ftpIn = new TelnetInputStream(new
FileInputStream(source), true);
byte[] buf = new byte[204800];
int bufsize = 0;
while ((bufsize = ftpIn.read(buf, 0, buf.length)) != -1) {
ftpOut.write(buf, 0, bufsize);
}
ftpIn.close();
ftpOut.close();
}
/**
* JSP 中的流上传到 FTP 服务器,
* 上传文件只能使用二进制模式,当文件存在时再次上传则会覆盖 * 字节数组做为文件的输入流,此方法适用于 JSP 中通过
* request 输入流来直接上传文件在 RequestUpload 类中调用了此方法,
* destination 路径以 FTP 服务器的"/"开始,带文件名
* @param sourceData byte[]
* @param destination String
* @throws Exception
*/
public void upFile(byte[] sourceData, String destination) throws Exception {
buildList(destination.substring(0, destination.lastIndexOf("/")));
ftpclient.binary(); //此行代码必须放在 buildList 之后
TelnetOutputStream ftpOut = ftpclient.put(destination);
ftpOut.write(sourceData, 0, sourceData.length);
// ftpOut.flush();
ftpOut.close();
}
/**
* 从 FTP 文件服务器上下载文件 SourceFileName,到本地 destinationFileName
* 所有的文件名中都要求包括完整的路径名在内
* @param SourceFileName String
* @param destinationFileName String
* @throws Exception
*/ public void downFile(String SourceFileName, String destinationFileName) throws
Exception {
ftpclient.binary(); //一定要使用二进制模式
TelnetInputStream ftpIn = ftpclient.get(SourceFileName);
byte[] buf = new byte[204800];
int bufsize = 0;
FileOutputStream ftpOut = new FileOutputStream(destinationFileName);
while ((bufsize = ftpIn.read(buf, 0, buf.length)) != -1) {
ftpOut.write(buf, 0, bufsize);
}
ftpOut.close();
ftpIn.close();
}
/**
*从 FTP 文件服务器上下载文件,输出到字节数组中
* @param SourceFileName String
* @return byte[]
* @throws Exception
*/
public byte[] downFile(String SourceFileName) throws
Exception {
ftpclient.binary(); //一定要使用二进制模式 TelnetInputStream ftpIn = ftpclient.get(SourceFileName);
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
byte[] buf = new byte[204800];
int bufsize = 0;
while ((bufsize = ftpIn.read(buf, 0, buf.length)) != -1) {
byteOut.write(buf, 0, bufsize);
}
byte[] return_arraybyte = byteOut.toByteArray();
byteOut.close();
ftpIn.close();
return return_arraybyte;
}
/**调用示例
* FtpUpfile fUp = new FtpUpfile("192.150.189.22", 21, "admin", "admin");
* fUp.login();
* fUp.buildList("/adfadsg/sfsdfd/cc");
* String destination = "/test.zip";
* fUp.upFile("C:\\Documents and Settings\\Administrator\\My
Documents\\sample.zip",destination);
* ArrayList filename = fUp.fileNames("/");
* for (int i = 0; i < filename.size(); i++) { * System.out.println(filename.get(i).toString());
* }
* fUp.logout();
* @param args String[]
* @throws Exception
*/
public static void main(String[] args) throws Exception {
FtpUpfile fUp = new FtpUpfile("172.16.0.142", 22, "ivr", "ivr");
fUp.login();
/* fUp.buildList("/adfadsg/sfsdfd/cc");
String destination = "/test/SetupDJ.rar";
fUp.upFile(
"C:\\Documents and Settings\\Administrator\\My Documents\\SetupDJ.rar",
destination);
ArrayList filename = fUp.fileNames("/");
for (int i = 0; i < filename.size(); i++) {
System.out.println(filename.get(i).toString());
}
fUp.downFile("/sample.zip", "d:\\sample.zip");
*/
FileInputStream fin = new FileInputStream(
"d:\\wapPush.txt"); byte[] data = new byte[20480000];
fin.read(data, 0, data.length);
fUp.upFile(data, "/home/cdr/wapPush.txt");
fUp.logout();
System.out.println("程序运行完成!");
/*FTP 远程命令列表
USER PORT RETR ALLO DELE SITE XMKD CDUP FEAT
PASS PASV STOR REST CWD STAT RMD XCUP OPTS
ACCT TYPE APPE RNFR XCWD HELP XRMD STOU AUTH
REIN STRU SMNT RNTO LIST NOOP PWD SIZE PBSZ
QUIT MODE SYST ABOR NLST MKD XPWD MDTM PROT
*/
/*在服务器上执行命令,如果用sendServer来执行远程命令(不能执行本地FTP命令)的话,
所有 FTP 命令都要加上\r\n
ftpclient.sendServer("XMKD /test/bb\r\n"); //执行服务器上的 FTP 命令
ftpclient.readServerResponse 一定要在 sendServer 后调用
nameList("/test")获取指目录下的文件列表
XMKD建立目录,当目录存在的情况下再次创建目录时报错
XRMD 删除目录
DELE 删除文件
*/ }
}
2、apache 的 common.net
package com.ftp;
import java.io.*;
import java.net.InetAddress;
import org.apache.commons.net.ftp.*;
import org.apache.commons.net.ftp.parser.*;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPFileEntryParser;
import sun.net.TelnetInputStream;
public class FtpAppache {
public FtpAppache() throws Exception{
// sun.net.ftp.FtpClient ft = null;
// TelnetInputStream t = ft.list();
// t.setStickyCRLF(true);
} public void test1() throws Exception {
//
String strTemp = "";
//InetAddress ia = InetAddress.getByName("192.168.0.193");
FTPClient ftp = new FTPClient();
ftp.connect("172.16.0.142",22 );
boolean blogin = ftp.login("ivr ", "ivr");
if (!blogin) {
System.out.println("连接失败");
ftp.disconnect ();
ftp = null;
return;
}
/*//如果是中文名必需进行字符集转换
boolean bMakeFlag = ftp.makeDirectory(new String("测试目录".getBytes(
"gb2312"), "iso-8859-1")); //在服务器创建目录
//上传文件到服务器,目录自由创建
File file = new File("c:\\test.properties");
ftp.storeFile("test.properties",new FileInputStream(file));*/
System.out.println( ftp.getSystemName ()); FTPFile[] ftpFiles = ftp.listFiles ();
if (ftpFiles != null) {
for (int i = 0; i < ftpFiles.length; i++) {
System.out.println(ftpFiles[i].getName());
//System.out.println(ftpFiles[i].isFile());
if (ftpFiles[i].isFile()) {
FTPFile ftpf = new FTPFile();
/*System.err.println(ftpf.hasPermission(FTPFile.GROUP_ACCESS,
FTPFile.EXECUTE_PERMISSION));
System.err.println("READ_PERMISSION="+ftpf.hasPermission(FTPFile.USER_A
CCESS,
FTPFile.READ_PERMISSION));
System.err.println("EXECUTE_PERMISSION="+ftpf.hasPermission(FTPFile.USE
R_ACCESS,
FTPFile.EXECUTE_PERMISSION));
System.err.println("WRITE_PERMISSION="+ftpf.hasPermission(FTPFile.USER_
ACCESS,
FTPFile.WRITE_PERMISSION));
System.err.println(ftpf.hasPermission(FTPFile.WORLD_ACCESS,
FTPFile.READ_PERMISSION));*/
}
//System.out.println(ftpFiles[i].getUser()); }
}
//下载服务器文件
FileOutputStream fos = new FileOutputStream("e:/proftpd-1.2.10.tar.gz");
ftp.retrieveFile("proftpd-1.2.10.tar.gz",fos );
fos.close();
//改变 ftp 目录
//ftp.changeToParentDirectory();//回到父目录
//ftp.changeWorkingDirectory("");//转移工作目录
//ftp.completePendingCommand();//
//删除 ftp 服务器文件
//ftp.deleteFile("");
//注销当前用户,
//ftp.logout();
//ftp.structureMount("");
ftp.disconnect ();
ftp = null;
}
/**
* 封装好的东西是好用,碰到这种问题,我们就。。。up * @param args String[]
*/
public static void main(String[] args) {
try {
FtpAppache ftpAppache1 = new FtpAppache();
ftpAppache1.test1();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
3、edtftpj
package com.boss;
import com.enterprisedt.net.ftp.FTPClient;
import com.enterprisedt.net.ftp.FTPMessageCollector;
import com.enterprisedt.net.ftp.FTPTransferType;
import com.enterprisedt.net.ftp.FTPConnectMode;
import com.enterprisedt.util.debug.Level;
import com.enterprisedt.util.debug.Logger; /**
* Simple test class for FTPClient
*
* @author Hans Andersen
* @author Bruce Blackshaw
*/
public class Demo {
/**
* Revision control id
*/
private static String cvsId = "@(#)$Id: Demo.java,v 1.6 2005/03/18 11:12:56 bruceb Exp
{1}quot;;
/**
* Log stream
*/
private static Logger log = Logger.getLogger(Demo.class);
/**
* Standard main()
*
* @param args standard args */
public static void main(String[] args) {
// assign args to make it clear
String host = "172.16.0.142";
String user = "ivr";
String password = "ivr";
Logger.setLevel(Level.ALL);
FTPClient ftp = null;
try {
// set up client
ftp = new FTPClient();
ftp.setRemoteHost(host );
ftp.setRemotePort(22 );
ftp.setConnectMode(FTPConnectMode.ACTIVE );
FTPMessageCollector listener = new FTPMessageCollector();
ftp.setMessageListener(listener );
//ftp.setAutoPassiveIPSubstitution(true); // connect
log.info("Connecting");
ftp.connect ();
// login
log.info("Logging in");
ftp.login(user , password);
// set up passive ASCII transfers
log.debug("Setting up passive, ASCII transfers");
ftp.setConnectMode(FTPConnectMode.PASV );
ftp.setType(FTPTransferType.ASCII );
// get directory and print it to console
log.debug("Directory before put:");
String[] files = ftp.dir (".", true);
for (int i = 0; i < files.length; i++)
log.debug(files[i]);
// copy file to server
log.info("Putting file");
ftp.put("test.txt ", "test.txt");
// get directory and print it to console
log.debug("Directory after put"); files = ftp.dir (".", true);
for (int i = 0; i < files.length; i++)
log.debug(files[i]);
// copy file from server
log.info("Getting file");
ftp.get("test.txt " + ".copy", "test.txt");
// delete file from server
log.info("Deleting file");
ftp.delete("test.txt ");
// get directory and print it to console
log.debug("Directory after delete");
files = ftp.dir ("", true);
for (int i = 0; i < files.length; i++)
log.debug(files[i]);
// Shut down client
log.info("Quitting client");
ftp.quit ();
String messages = listener.getLog();
log.debug("Listener log:");
log.debug(messages); log.info("Test complete");
} catch (Exception e) {
log.error("Demo failed", e);
}
}
/**
* Basic usage statement
*/
public static void usage() {
System.out.println("Usage: Demo remotehost user password");
}
}
4、sshtools,maverick-ssh.jar
package com.sshtools.examples.echo;
import com.sshtools.j2ssh.configuration.SshConnectionProperties;
import com.sshtools.j2ssh.authentication.*;
import com.sshtools.j2ssh.transport.*;
import com.sshtools.j2ssh.SshException;
import org.apache.log4j.Logger; import java.io.*;
import com.sshtools.j2ssh.subsystem.*;
/**
*
* <p>Echo Client</p>
* <p>Provides a simple example of using the sshtools subsystem framework</p>
* <p>Copyright: Copyright (c) 2002 Lee David Painter</p>
* <p>Company: Sshtools.com</p>
* @author Lee David Painter
* @version 1.0
*/
public class EchoClient extends SubsystemClient {
private static Logger log = Logger.getLogger(EchoClient.class);
/**
* Contructor for the echo client object
*/
public EchoClient() {
super("echo", true);
registerSubsystemMessage(EchoMessage.SSH_ECHO_MESSAGE, EchoMessage.class);
} /**
* Sends a string to the remote ssh server and waits for the same string
* to be echoed back
* @param msg
*/
public void sendEcho(String msg) {
try {
EchoMessage echo = new EchoMessage(msg);
this.sendMessage(echo);
SubsystemMessage reply = nextMessage();
if(reply.getMessageType()== EchoMessage.SSH_ECHO_MESSAGE) {
System.out.println("Server echo> " + ((EchoMessage)reply).getMessage());
}
}
catch(SshException e) {
e.printStackTrace();
}
} /**
* Entry point for the EchoClient sample application
* @param args
*/
public static void main(String args[]) {
try {
org.apache.log4j.BasicConfigurator.configure();
EchoClient client = new EchoClient();
SshConnectionProperties properties = new SshConnectionProperties();
properties.setHost("172.106.0.142");
properties.setUsername("ivr");
final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
client.connect(properties, new HostKeyVerification() {
public void onDeniedHost(String host) {
System.out.println("Access to the host " + host + " is denied from this
system");
}
public void onHostKeyMismatch(String host, String fingerprint, String actual) { try {
System.out.println("The host key supplied by " + host + " is: " + actual);
System.out.println("The current allowed key for " + host + " is: " +
fingerprint);
getResponse(host, actual);
}
catch(Exception e) {
e.printStackTrace();
}
}
private void getResponse(String host, String fingerprint)
throws InvalidHostFileException,
IOException {
String response = "";
while(!(response.equalsIgnoreCase("YES") ||
response.equalsIgnoreCase("NO")
|| response.equalsIgnoreCase("ALWAYS"))) {
System.out.print("Do you want to allow this host key? [Yes|No|Always]:
");
response = reader.readLine();
} if(response.equalsIgnoreCase("YES"))
allowHost(host, fingerprint, false);
if(response.equalsIgnoreCase("NO")) {
System.out.println("Cannot continue without a valid host key");
System.exit(1);
}
if(response.equalsIgnoreCase("ALWAYS"))
allowHost(host, fingerprint, true);
}
public void onUnknownHost(String host, String fingerprint) {
try {
System.out.println("The host " + host + " is currently unknown to the
system");
System.out.println("The host key fingerprint is: " + fingerprint);
getResponse(host, fingerprint);
}
catch(Exception e) {
e.printStackTrace();
} }
});
PasswordAuthentication password = new PasswordAuthentication();
password.setPassword("ivr");
password.setUsername("ivr");
client.authenticate(password);
String message;
do {
System.out.print("Message> ");
message = reader.readLine();
client.sendEcho(message);
} while(!message.equalsIgnoreCase("EXIT"));
client.close();
}
catch(SshException e) {
e.printStackTrace();
}
catch(IOException ioe) { ioe.printStackTrace();
}
}
}
相关推荐
基于Coze平台从零构建AI智能体:以测试用例生成为例的实战指南
在人工智能技术快速发展的今天,大语言模型(LLM)和提示词工程(Prompt Engineering)已成为构建智能应用的核心技术。其原理在于通过自然语言指令引导模型完成特定任务,其技术价值在于极大地降低了AI应用开发的门槛,使非专业开发者也能快速实现想法。这一技术广泛应用于自动化办公、智能客服、内容生成等场景。本文聚焦于字节跳动旗下的Coze平台,该平台通过可视化工作流编排和预置技能,将上述技术封装为易用的工具。文章以“根据产品需求文档(PRD)自动生成测试用例”这一具体场景为例,详细拆解了从需求分析、工
JAVA实现FTP服务器上文件上传下载以及文件在线预览
(一)介绍文件上传下载: (1)前端思路: 用formData封装好file以及相关参数,然后l利用ajax请求往后台传数据 html的代码: <input id="cm_file" type="file" name="upFileName"> js代码: var formData = new FormData()...
Hodgkin-Huxley Model
介绍了经典的动力学模型:HH Model
Java从FTP服务器中获取PDF文件数据
Java 直接读取本地磁盘的PDF文件很容易,但是要从FTP中获取文件数据缺需要使用工具来连接到FTP服务器,之后才能从中获取到相应的文件数据 操作系统类型:windows 开发工具: idea 项目管理:maven 需要的jar包 <!-- commons jar --> <dependency> <groupId>org.ap...
lammps教程:非晶sio2建模方法
大家好,我是小马老师。 本文介绍非晶sio2的建模方法。 sio2的建模方法有很多,可以下载cif文件使用atomsk转为data文件,也可以直接在ms中导入sio2结构,这些方法建的sio2都是标准的sio2晶体。 如果要建立非晶状态的sio2,就是把排列规则的sio2变成无序排列的sio2。 非晶建模方法有很多,在lammps中,可以通过高温高压的方法打乱sio2的排列实现非晶建模。 代码中的温度和步数可根据需要自己调整。 下面给出in文件案例代码。 units metal atom
【局部规划模块曲线算法】曲线平滑介绍
本文先对轨迹平滑问题做个简单的介绍,具体内容后续再更,其他模块可以参考去我其他文章提示:以下是本篇文章正文内容(1)适合给移动机器人运动的路径【满足运动学,高阶平滑】(2)高阶的运动学不能够突变的【至少三阶的加速度不能突变,最好四阶的jerk和五阶的snap也不能突变】(3)在转弯的地方不会停下来(4)加减速均衡,节省能量(5)节省时间的。
Java实现Ftp文件下载及图片预览
通过浏览器的方式下载ftp文件及图片流方式实现页面预览FTP图片
华为OD机试真题 新系统2026-04-01 Java&Go【计算数列位置N的值】
如果其前面的M个元素中,存在值相同的元素,则该位置上的数值等于前面M个数中最大的数值与最小的数值之如果其前面的M个元素中,不存在值相同的元素,则该位置上的数值等于前面M个数中最大的数值与最小的数值之差;1、输入M、N两个数,则按照以下规则形成一个数列;两个整数,用逗号分割,分别表示M和N。一个整数,表示数列第N个位置上的数值。2、数列的前M个元素的值为1到M;请计算该数列第N个位置上的数值。N取值范围:1<= N<=50。M取值范围:3<=M<=10。
java读取pdf文件内容
java读取pdf文件内容 在java中要读取pdf文件内容,我们可以借助第三方软件实现。常用的是xpdf,本文就简单介绍在linux下如何安装xpdf,及在java中如何利用xpdf读取pdf文件内容。一.安装xpdf 在fc系列下,不用安装,可以直接yum,但是笔者建议还是下载安装的好,因为笔者曾经碰到过这样的问题,客户服务器上的xpdf是yum安装的,有
YOLOv11的对比学习预训练改进-(通过SimCLR预训练增强特征提取)
本文介绍了将SimCLR对比学习预训练与YOLOv11目标检测模型相结合的创新方法。文章首先概述了目标检测领域的发展现状和YOLOv11的架构优化,包括主干网络、特征金字塔和检测头的改进设计。其次详细解析了SimCLR对比学习的核心原理,涵盖数据增强、投影头设计和NT-Xent损失函数。最后探讨了如何将对比学习与目标检测有效结合,通过特征空间对齐和渐进式微调策略提升模型性能。该方法显著增强了特征提取能力,提高了检测精度和训练效率,特别是在小目标和遮挡目标的检测上表现突出。
SAP 采购员参数及权限配置
若要控制采购员的参数缺省值或者权限,可以通过以下方式实现: 1、定义采购员缺省值(EVO) 路径:后台----物料管理---采购---环境数据---定义采购员的缺省值 点击图标,显示如下,查看参数配置ID: 查询到配置“定义采购员的缺省值”是通过ID “EVO”来配置的。进入页面建立配置: 按照需要配置新条目: 事务代码SU01进入用户配置页面,在用户“参数”页面配置前面设...
java 文件上传到ftp_java上传文件到FTP
import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.io.OutputStream;import org.apache.commons.net.ftp.FTPClient;import org.apache....
【嵌入式DIY实例-ESP32篇】-智能花园助手
本文介绍了一个基于ESP32的智能花园监控系统。系统使用ESP-EYE摄像头开发板,集成了土壤湿度传感器、DHT22温湿度传感器和电磁阀等模块,实现植物生长环境监测与自动灌溉功能。硬件部分详细说明了各传感器的接线方式,软件部分展示了如何通过Firebase实现数据存储和远程监控。系统可实时采集土壤湿度、空气温湿度等数据,并通过摄像头监控植物状态,当检测到环境参数异常时,可自动控制水泵进行灌溉,为植物提供最佳生长环境。
HTML转PDF并上传FTP(1)
准备工作: 1.安装插件wkhtmltopdf,URL:https://wkhtmltopdf.org/downloads.html 2.导包 jsch-0.1.54.jar URL:http://www.jcraft.com/jsch/ 代码片段 /*wkhtmltopdf在linux服务器中的路径/ private static final String toPdf
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
IEM模型,地表粗糙度模拟
利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟
java实现url的word地址转换为pdf文件操作(文件最终存储ftp里nginx映射展示,项目部署到k8s里)
上周分配的任务功能是将word转化为pdf文件,在转换的过程中还需要替换文档内容(ps不会将原有内容文档更改),查询了一些资料发现java还是蛮难实现的,资料也是不多的,尤其我们的环境还是k8s里部署,就增大了很多困难,实践了很久最终成功将word转换成pdf文件了。 首先给我的word地址是url方式的地址,"http://ip/文件名称.docx"的http方式,我需要请求这个地址转换成in...
VB摄像头监控
该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制
实现FTP服务器免登陆下载PDF文件转base64在下载到本地|服务器
最近碰到一个问题,就是实现调用FTP服务器免登陆下载在进行展示,在这里分享下源码,能帮助到你的请点个赞呐呐呐! 上源码+注释 import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import...
数学建模模型总结
这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!
从FTP获取PDF文件流并展示到页面
背景描述:从FTP获取PDF,并将其展示到页面,以达到预览的效果 Java:代码 ftpClient.connnect(ip,port); ftpClient.setFileType(FTP,.BINARY_FILE_TYPE); ftpClient.login(userId,password); ftpClient.changeWorkingDirec
Spring Boot 读取 FTP文件
需求:从FTP文件服务器里获取PDF文件。2、配置properties文件。废话不多说,直接开干。
ftp工具类
import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetSocketAdd...
【技术底稿 18】FTP 文件处理 + LibreOffice Word 转 PDF 在线预览 + 集群乱码终极排查全记录
本文为后端通用文件处理实战复盘,基于 LibreOffice 实现 FTP 存储 Word 转 PDF 在线预览能力,支持 iframe 直连预览与下载双模式。完整排查 FTP 连接污染、分布式集群交替乱码问题,深度定位字体渲染根因并完成根治,沉淀 FTP 开发规范与集群环境一致性运维可复用经验。
word转pdf实现总结
之前项目有需求,要求java代码实现word转pdf功能.调研了很多技术都不是很成熟.特别是中文乱码的问题.大部分框架都是在中文环节出了问题.(我很奢望我能出生在一个英语国度).最终的技术选型是利用jacob实现word转pdf功能.但是服务器部署在linux服务器上.所以又产生了新的问题就是:linux和windows交互文件.这个问题还是比较容易解决的.windows上用的是pscp.exe向
【java】简单的文件加密解密方式
简单的文件加密解密方式
SPRINGMVC实现在线预览功能(openOffice)
这两天因业务需要,做了个在线预览的功能。其实在线预览本身并不复杂,只要调用相应的控件即可完成。 因为文件在FTP服务器上,所以我现将FTP服务器上相对应的文件下载到本地工程文件夹里(resource/pdf/),然后再在本地通过OpenOffice将word文件(本文以word为例)转换成PDF文件,在JSP页面通过pdfobject.js将resource/pdf/下对应的文件取出,预览。不多说
访问登录linux预览文件,包括图片,pdf,word
话不多说,上代码 public static FTPClientForTree getInstance() { if (ftpClientUtil == null) { ftpClientUtil = new FTPClientForTree(); } return ftpClientUtil; } FTPClientForTree.getInstance(). viewImage(orderFileReport.getFilePath(),orderFileReport.ge
【四、java实现气象预报数据micaps-diamond4的数据解析入库】
此类数据处理的核心重点,数据解析入库存在数据实时更新的情况,那么数据库表中的数据要进行实时更新覆盖才可以哦!第二类:实时数据:ZLkFile/JmDx2019 and ZLkFile/ZdDx2019。第二类:实时数据:ZLkFile/ScZdJmDxZLk/ZdDx2022。数据可能存在修改覆盖的情况,要使用定时任务实现数据不断的覆盖更新。第一类:气象预报数据:JC_Rain//diamond4。第一类:气象预报数据:JC_Rain//diamond4。第三类:气象天气预报文档数据:tqyb。
Mail工具类
1.mailimport java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import javax.mail...
337



被折叠的 条评论
为什么被折叠?



