求一个Java实现自动下载的源代码您好,这样的:
/**
*
*/
package com.b510.base.bean.install;
import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author hongten(hongtenzone@foxmail.com)
* @date 2013-2-24
*/
@SuppressWarnings("unchecked")
public class BeanUtils {
//公共部分
private static final String RT_1 = "\r\n";
private static final String RT_2 = RT_1+RT_1;
private static final String BLANK_1 =" ";
private static final String BLANK_4 ="";
private static final String BLANK_8 =BLANK_4 + BLANK_4;
//注释部分
private static final String ANNOTATION_AUTHOR_PARAMTER = "@author ";
private static final String ANNOTATION_AUTHOR_NAME = "hongten(hongtenzone@foxmail.com)";
private static final String ANNOTATION_AUTHOR = ANNOTATION_AUTHOR_PARAMTER + ANNOTATION_AUTHOR_NAME;
private static final String ANNOTATION_DATE = "@date ";
private static final String ANNOTATION = "/**"+RT_1+BLANK_1+"*"+BLANK_1+ANNOTATION_AUTHOR +RT_1+BLANK_1+"*"+BLANK_1+ANNOTATION_DATE +getDate()+RT_1+BLANK_1+"*/"+RT_1;
//文件 地址
//private static final String BEAN_PATH = "com/b510/base/bean";
private static final String DAO_PATH = "com/b510/base/dao";
private static final String DAO_IMPL_PATH = "com/b510/base/dao/impl";
private static final String SERVICE_PATH = "com/b510/base/service";
private static final String SERVICE_IMPL_PATH = "com/b510/base/service/impl";
//包名
private static final String BEAN_URL = "com.b510.base.bean";
private static final String DAO_URL = "com.b510.base.dao";
private static final String DAO_IMPL_URL = "com.b510.base.dao.impl";
private static final String SERVICE_URL = "com.b510.base.service";
private static final String SERVICE_IMPL_URL = "com.b510.base.service.impl";
//基本类名称
private static final String BASE_DAO_NAME = DAO_URL + ".BaseDao";
private static final String ABSTRACT_BASE_DAO_IMPL_NAME = DAO_IMPL_URL + ".AbstractBaseDaoImpl";
private static final String BASE_SERVICE_NAME = SERVICE_URL + ".BaseService";
private static final String ABSTRACT_BASE_SERVICE_IMPL_NAME = SERVICE_IMPL_URL + ".AbstractBaseServiceImpl";
/**
* 创建bean的Daobr
*
* @param c
* @throws Exception
*/
public void createBeanDao(Class c) throws Exception {
String cName = c.getName();
String fileName = System.getProperty("user.dir") + "/src/" + DAO_PATH
+ "/" + getLastChar(cName) + "Dao.java";
File f = new File(fileName);
FileWriter fw = new FileWriter(f);
fw.write("package "+DAO_URL+";"+RT_2+ANNOTATION+"public interface " +
getLastChar(cName) + "Dao extends "+BASE_DAO_NAME+" " + cName + " {"+RT_2+"}");
fw.flush();
【java云盘源代码 javaweb源码百度云】fw.close();
showInfo(fileName);
}
/**
* 创建bean的Dao的实现类
* @param c
* @throws Exception
*/
public void createBeanDaoImpl(Class c) throws Exception{
String cName = c.getName();
String fileName = System.getProperty("user.dir") + "/src/" + DAO_IMPL_PATH
+ "/" + getLastChar(cName) + "DaoImpl.java";
File f = new File(fileName);
FileWriter fw = new FileWriter(f);
fw.write("package "+DAO_IMPL_URL+";"+RT_2+ANNOTATION+"public class " +
getLastChar(cName) + "DaoImpl extends "+ABSTRACT_BASE_DAO_IMPL_NAME+"" +
cName + " implements "+DAO_URL+"."+getLastChar(cName)+"Dao{"+RT_2+"}");
fw.flush();
fw.close();
showInfo(fileName);
}
/**
* 创建bean的service
* @param c
* @throws Exception
*/
public void createBeanService(Class c) throws Exception{
String cName = c.getName();
String fileName = System.getProperty("user.dir") + "/src/" + SERVICE_PATH
推荐阅读
- 多种故事角色扮演游戏,经典故事角色扮演
- sqlserver链接错误,sql2016连接服务器失败
- php数据类型转化的值,php中数据类型转换分为
- 显卡供电线怎么接,显卡供电线怎么接图
- php第三章数据库员工 php数据库编程
- mysqlip地址数据库,mysql的ip怎么看
- pdf在线免费转word,pdf转word免费的软件在线
- 大众直播技巧视频,大众直播tv
- linux中su命令错误 linuxsudo命令用不了