我通过读取XML里面的配置,调用配置信息,在遍历XML信息里调用shift()方法没反映,下面是代码可以帮我看看吗?
运行时没报错
读取XML代码: //获取回传XML配置信息
public List<FTPRead> getXml()
{
List<FTPRead> listftp = new ArrayList<FTPRead>();
java.io.File file=new java.io.File("src//test.xml");
//创建一个读取XML文件的对象
SAXReader reader=new SAXReader();
//创建一个文档对象
Document document; FTPRead read=new FTPRead();
try
{
document = reader.read(file);
//获取文件的根节点
Element element=document.getRootElement();
for(Iterator i=element.elementIterator("disk");i.hasNext();){
//获取节点元素
element=(Element)i.next();
String name=element.attributeValue("name");
read.setName(name); //存储本地文件路径
String Localpath=element.elementText("Localpath");//取disk子元素capacity的内容
read.setLocalpath(Localpath);
//上传FTP目录
String ftppath=element.elementText("ftppath");
read.setFtppath(ftppath);
//回传FTP IP地址
String FTPIP=element.elementText("FTPIP");
read.setFTPIP(FTPIP);
//Ftp端口号
int port=Integer.parseInt(element.elementText("port"));
read.setPort(port);
//FTP登录帐号
String username=element.elementText("username");
read.setUsername(username);
//FTP登录密码
String password=element.elementText("password");
read.setPassword(password);
listftp.add(read);
}
} catch (DocumentException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return listftp;
}
数据上传代码:
//数据转移
public static void shift(String name,String Localpath,String ftppath,String FTPIP, int port,String username,String password)
{
List listSpecies = TxTtoFtpaAtion.getTextFile(Localpath);
System.out.println("上传始");
for (int j = 0; j < listSpecies.size(); j++)
{
//获取txt的文件路径名
String filepath ;
//获取txt的文件名
String filename;
//获取.OK 的文件路径名
String filepathok;
//获取.OK的文件名
String filenameok;
System.out.println("上传开始");
boolean flag;
// a=drg.substring(24);
filepath = listSpecies.get(j).toString();
System.out.println(filepath);
filename = filepath
.substring(Localpath.length() + 1);
// 获取当前txt文件所对应的.ok文件路径
filepathok = filepath.replace("txt", "ok");
System.out.println(filepathok);
// 获取当前txt文件所对应的.ok文件名 filenameok = filepathok
.substring(Localpath.length() + 1);
if(filename.contains(".txt"))
{
//FTP上传方法
flag=FileTool.upLoadFromProduction(FTPIP,port, username,
password, ftppath,filename, filepath);
//FTP上传方法
if(flag)
{
flag=FileTool.upLoadFromProduction(FTPIP,port, username,
password, ftppath,filenameok, filepathok);
TxTtoFtpaAtion.copyFile(filepath, Localpath+"\\"+filename);
TxTtoFtpaAtion.deleteFile(filepath);
System.out.println(filepathok);
System.out.println(filenameok);
TxTtoFtpaAtion.copyFile(filepathok, Localpath+"\\"+filenameok);
TxTtoFtpaAtion.deleteFile(filepathok);
}
}
System.out.println("上传结束");
}
}
//调用
public static void main(String[] args) throws IOException
{
run();
} private static void run()
{
// TODO Auto-generated method stub
List<FTPRead> listftp= getXml();
for (FTPRead ftpRead : listftp)
{ String name=ftpRead.getName(); String Localpath=ftpRead.getLocalpath(); String ftppath=ftpRead.getFtppath(); String FTPIP=ftpRead.getFTPIP(); int port=ftpRead.getPort(); String username=ftpRead.getUsername();
String password=ftpRead.getPassword();
//读取本地文件路径目录下的.txt和.ok文件
shift(name,Localpath,ftppath,FTPIP,port,username,password);//调用了这个方法没反映
System.out.println("开始");
}
}JavaXML异常String行业数据
运行时没报错
读取XML代码: //获取回传XML配置信息
public List<FTPRead> getXml()
{
List<FTPRead> listftp = new ArrayList<FTPRead>();
java.io.File file=new java.io.File("src//test.xml");
//创建一个读取XML文件的对象
SAXReader reader=new SAXReader();
//创建一个文档对象
Document document; FTPRead read=new FTPRead();
try
{
document = reader.read(file);
//获取文件的根节点
Element element=document.getRootElement();
for(Iterator i=element.elementIterator("disk");i.hasNext();){
//获取节点元素
element=(Element)i.next();
String name=element.attributeValue("name");
read.setName(name); //存储本地文件路径
String Localpath=element.elementText("Localpath");//取disk子元素capacity的内容
read.setLocalpath(Localpath);
//上传FTP目录
String ftppath=element.elementText("ftppath");
read.setFtppath(ftppath);
//回传FTP IP地址
String FTPIP=element.elementText("FTPIP");
read.setFTPIP(FTPIP);
//Ftp端口号
int port=Integer.parseInt(element.elementText("port"));
read.setPort(port);
//FTP登录帐号
String username=element.elementText("username");
read.setUsername(username);
//FTP登录密码
String password=element.elementText("password");
read.setPassword(password);
listftp.add(read);
}
} catch (DocumentException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return listftp;
}
数据上传代码:
//数据转移
public static void shift(String name,String Localpath,String ftppath,String FTPIP, int port,String username,String password)
{
List listSpecies = TxTtoFtpaAtion.getTextFile(Localpath);
System.out.println("上传始");
for (int j = 0; j < listSpecies.size(); j++)
{
//获取txt的文件路径名
String filepath ;
//获取txt的文件名
String filename;
//获取.OK 的文件路径名
String filepathok;
//获取.OK的文件名
String filenameok;
System.out.println("上传开始");
boolean flag;
// a=drg.substring(24);
filepath = listSpecies.get(j).toString();
System.out.println(filepath);
filename = filepath
.substring(Localpath.length() + 1);
// 获取当前txt文件所对应的.ok文件路径
filepathok = filepath.replace("txt", "ok");
System.out.println(filepathok);
// 获取当前txt文件所对应的.ok文件名 filenameok = filepathok
.substring(Localpath.length() + 1);
if(filename.contains(".txt"))
{
//FTP上传方法
flag=FileTool.upLoadFromProduction(FTPIP,port, username,
password, ftppath,filename, filepath);
//FTP上传方法
if(flag)
{
flag=FileTool.upLoadFromProduction(FTPIP,port, username,
password, ftppath,filenameok, filepathok);
TxTtoFtpaAtion.copyFile(filepath, Localpath+"\\"+filename);
TxTtoFtpaAtion.deleteFile(filepath);
System.out.println(filepathok);
System.out.println(filenameok);
TxTtoFtpaAtion.copyFile(filepathok, Localpath+"\\"+filenameok);
TxTtoFtpaAtion.deleteFile(filepathok);
}
}
System.out.println("上传结束");
}
}
//调用
public static void main(String[] args) throws IOException
{
run();
} private static void run()
{
// TODO Auto-generated method stub
List<FTPRead> listftp= getXml();
for (FTPRead ftpRead : listftp)
{ String name=ftpRead.getName(); String Localpath=ftpRead.getLocalpath(); String ftppath=ftpRead.getFtppath(); String FTPIP=ftpRead.getFTPIP(); int port=ftpRead.getPort(); String username=ftpRead.getUsername();
String password=ftpRead.getPassword();
//读取本地文件路径目录下的.txt和.ok文件
shift(name,Localpath,ftppath,FTPIP,port,username,password);//调用了这个方法没反映
System.out.println("开始");
}
}JavaXML异常String行业数据
解决方案 »
- hibernate的动态查询用来解决什么实际问题?
- struts2 中隐藏表格列问题
- XML中重复数据合并的问题!
- 如此错误:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- ■■■各位大虾,javamail怎么发送多行数据
- 关于jsp文件上传问题问题
- ssh注解实体关系配置问题
- IIS和TOMCAT5的整合问题
- spring调用ejb的问题
- jsvc-CPU总是100%,导出堆践,大家帮忙看看
- jsp页面中,一个table数据有很多列,很多行,有上下左右滚动条,怎样可以表格数据拖动的时候,表头不动?
- 我是一个新手, weblogic 10的URL怎么写?
楼主debugger吧 调试一下先确定问题
这么一大坨代码很少有人给你调试