`
mimang2007110
  • 浏览: 232820 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论
文章列表
1、利用System.getProperty()函数获取当前路径: System.out.println(System.getProperty("user.dir"));//user.dir指定了当前的路径 2、使用File提供的函数获取当前路径: File directory = new File("");//设定为当前文件夹 try{ System.out.println(directory.getCanonicalPath());//获取标准的路径 System.out.println(directory.getA ...

java udp通信

java服务器部分: public static void main(String[] args) { try { DatagramSocket server = new DatagramSocket(5050); byte[] recvBuf = new byte[100]; DatagramPacket recvPacket = new DatagramPacket(recvBuf, recvBuf.length); server.re ...
  package com.tw.ftp; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import org.apache.commons.io.IOUtils; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPReply; /** *<p>ftp连接管理(使用apache commons-net-1.4.1 lib)&l ...
上传文件到FTP服务器: /** * Description: 向FTP服务器上传文件 * @param url FTP服务器hostname * @param port FTP服务器端口,如果默认端口请写-1 * @param username FTP登录账号 * @param password FTP登录密码 * @param path FTP ...
  try { // path是指欲下载的文件的路径。 String path = "D:/file/aa.zip"; File file = new File(path); // 取得文件名。 String filename = file.getName(); // 取得文件的后缀名。 String ext = filename.substring(filename.last ...
package com.mvc.interceptor; import java.io.File; import java.io.IOException; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.fileupload.FileItem; import ...
  // 存储服务器的响应消息 String responseMsg = ""; // 如果服务器地址不为空,则执行发送命令 if (!Global.isEmpty(address)) { // 客户端对象 HttpClient client = new HttpClient(); // POST对象 PostMethod method = new P ...
else if(actione.getName().equals("interceptor-ref")){ if(null==interceptorlist){ interceptorlist=new ArrayList<InterceptorInfo>(); } String infoname=actione.attributeValue("name"); InterceptorInfo interinfo=null; for(Intercept ...
else if(e.getName().equals("interceptor-stack")){ if(null==stackmap){ stackmap=new HashMap<String, InterceptorStack>(); } InterceptorStack stack=new InterceptorStack(); stack.setStackname(e.attributeValue("name")); List<InterceptorInfo ...
public static void getXMLInfo(String filelocation){ String filename=BeifengMVCXMLFactory.class.getResource("/"+filelocation).getFile(); File file=new File(filename); SAXReader reader=new SAXReader(); Document doc=null; Package pack=null; BeifengMvc mvc=new BeifengMvc(); ...
客户端代码: try { // 创建连接对象并呼叫AP SOAPConnection conn = SOAPConnectionFactory.newInstance().createConnection(); SOAPMessage resMsg = conn.call(reqMsg, apUrl); // 获取AP的响应消息 String msg = &q ...
下面的代码可以把字符串转换成SoapMessage对象 /** * <把soap字符串格式化为SOAPMessage> * <功能详细描述> * @param soapString * @return * @see [类、类#方法、类#成员] */ public static SOAPMessage formartSoapString(String soapString) { MessageFactory msgFactory; try ...
下面的代码可以把一个SoapMessage对象转换成字符串对象   SOAPConnection conn = SOAPConnectionFactory.newInstance().createConnection(); SOAPMessage resMsg = conn.call(reqMsg, url); Document doc = resMsg.getSOAPPart().getEnvelope().getOwnerDocument(); StringWriter output = new StringWriter(); TransformerFactory.newInst ...
public static void init(){ String filename=BeifengMVCXMLFactory.class.getResource("/beifengmvc.xml").getFile(); File file=new File(filename); SAXReader reader=new SAXReader(); Document doc=null; try { doc=reader.read(file); Element root=doc.getRootElement(); Eleme ...
public String upload(){ HttpSession session=ActionContext.getActionContext().getMap().getSession(); String filepath=session.getServletContext().getRealPath("/")+"image/"; File f=new File(filepath); if(!f.exists()){ f.mkdir(); } f=new File(filepath+"/&quo ...
Global site tag (gtag.js) - Google Analytics