易截截图软件、单文件、免安装、纯绿色、仅160KB

java FTP操作

 简单的写了个java对ftp的操作
用的是commons-net.jar包
FTPProxy.java
public class FTPProxy{
public FTPProxy()
{
super();
ftpClient = new FTPClient();
}
public FTPProxy(FTPBean entity)
{
this();
this.entity = entity;
}
private FTPBean entity;
private FTPClient ftpClient;
public void connection()
{
try
{
ftpClient.connect(entity.getServerIP());
ftpClient.login(entity.getUser(), entity.getPassword());
} catch (SocketException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
}
public void download()
{
FileOutputStream fos = null;
try
{
String remoteFile = entity.getSrcFile();
String remoteFileName = "";
if (0 == remoteFile.lastIndexOf("/"))
{
remoteFileName = remoteFile.substring(remoteFile
.lastIndexOf("/") + 1);
} else if (0 < remoteFile.lastIndexOf("/"))
{
remoteFileName = remoteFile.substring(remoteFile
.lastIndexOf("/") + 1);
String path = remoteFile.substring(0, remoteFile
.lastIndexOf("/"));
ftpClient.changeWorkingDirectory(path);
} else
{
remoteFileName = remoteFile;
}
fos = new FileOutputStream(entity.getTargetFile());
ftpClient.setBufferSize(1024 * 8);
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
ftpClient.retrieveFile(remoteFileName, fos);
} catch (IOException e)
{
e.printStackTrace();
} finally
{
try
{
fos.close();
ftpClient.disconnect();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
public void upload()
{
FileInputStream fis = null;
try
{
File srcFile = new File(entity.getSrcFile());
fis = new FileInputStream(srcFile);
ftpClient.setBufferSize(1024 * 8);
ftpClient.setControlEncoding("GBK");
String ftpPath = entity.getFtpPath();
if(null!=ftpPath&&!"".equals(ftpPath))
{
ftpClient.makeDirectory(ftpPath);
ftpClient.changeWo


相关文档:

二、新建一个java窗口

1、首先大家最好去下载一个designer 的eclipse 插件
2、然后放入eclipse 安装目录下的plugin目录下
3、重新启动eclipse
4  新建一个java swing project
5, 新建一个window,然后点运行,就会出现一个最简单的窗口。
当然,你也可以新建一个class Window,然后输入如下代码
import java.awt.Dimension;
import ......

java枚举类型

public class TestEnum {
    /*最普通的枚举*/
    public enum ColorSelect {
        red, green, yellow, blue;    
    }
   ......

Java 几种排序法

这里主要对8种排序算法做个总结,分别是插入排序,选择排序,冒泡排序,希尔排序,归并排序,堆排序,快速排序以及基数排序。
1、 插入排序
比较和交换的时间复杂度为O(n^2),算法自适应,对于数据已基本有序的情况,时间复杂度为O(n),算法稳定,开销很低,适合于数据已基本有序或者数据量小的情况。
public void ins ......

java 事务处理

如果对数据库进行多次操作,每一次的执行或步骤都是一个事务.如果数据库操作在某一步没有执行或出现异常而导致事务失败,这样有的事务被执行有的就没有被执行,从而就有了事务的回滚,取消先前的操作.....
JavaBean中使用JDBC方式进行事务处理
public int delete(int sID) {
  dbc = new DataBaseConnection();
  Connect ......

myeclipse注册机,java写的适用于所有版本


import java.io.*;
public class Test {
    public static String convert(String s) {
        if (s == null || s.length() == 0)
            return s;
        ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号