我通过读取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行业数据
解决方案 »
- 超新手,请帮忙!
- Dreamweaver布局
- Properties
- 警惕重表象、轻技术这个OA应用的大毒瘤,别让悲剧重演
- 一个小问题,大家有没有知道的
- struts 2 的 select 问题 请指教
- 怎样把STRINGBUFFER中的数据读出来 如:
- 关于tomcat中调用JNI函数是否存在共享冲突的问题……
- 连接db2的时候报错,请各位大哥指教!
- 创建时间段的数据库,每一年有几个周,每个周从几月几号到几月几号(时间戳也行),每一年有几个月,每个月的第一天与最后一天的日期(时间戳也行)
- jsp页面中,一个table数据有很多列,很多行,有上下左右滚动条,怎样可以表格数据拖动的时候,表头不动?
- 我是一个新手, weblogic 10的URL怎么写?
楼主debugger吧 调试一下先确定问题
这么一大坨代码很少有人给你调试