随笔-71  评论-5  文章-0  trackbacks-0
 




错误的原因:

     调用第三方支付,出现问题,起先以为是重启服务器造成的,后来查看源代码,运行,才发现,第三方回调时被拦截。


posted @ 2015-03-26 16:36 藤本蔷薇 阅读(164) | 评论 (0)编辑 收藏
String ids = "as,ad,sdf,qwe,rwer,wfv";
for(String id:ids.split(",")){
System.out.println(id);
}


结果:
as
ad
sdf
qwe
rwer
wfv
posted @ 2015-03-18 09:39 藤本蔷薇 阅读(432) | 评论 (2)编辑 收藏



  var arr = [{ name: "john", lang: "js" },{ name: "nailwl", lang: "jquery" },{ name: "吴磊", lang: "ext" }]; 
  $.each( arr, function(index, content)
  { 
   alert( "the man's no. is: " + index + ",and " + content.name + " is learning " + content.lang ); 
  });
posted @ 2015-03-17 16:18 藤本蔷薇 阅读(199) | 评论 (0)编辑 收藏


 InetAddress address=InetAddress.getLocalHost();

 System.out.println(address.getHostAddress());
posted @ 2015-03-12 18:55 藤本蔷薇 阅读(363) | 评论 (0)编辑 收藏
 /**
 * Description: 向FTP服务器上传文件
 * @Version      1.0
 * @param url FTP服务器hostname
 * @param port  FTP服务器端口
 * @param username FTP登录账号
 * @param password  FTP登录密码
 * @param path  FTP服务器保存目录
 * @param filename  上传到FTP服务器上的文件名
 * @param input  输入流
 * @return 成功返回true,否则返回false *
 */
public static boolean uploadFile(String url,int port,String username,String password,String path,String filename,InputStream input){
 boolean success = false;
 FTPClient ftp = new FTPClient();
 ftp.setControlEncoding("GBK");
 try {
  int reply;
  ftp.connect(url,port);// 连接FTP服务器
  // 如果采用默认端口,可以使用ftp.connect(url)的方式直接连接FTP服务器
  ftp.login(username, password);// 登录
  reply = ftp.getReplyCode();
  if (!FTPReply.isPositiveCompletion(reply)) {
   ftp.disconnect();
   return success;
  }
  ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
  ftp.makeDirectory(path);
  ftp.changeWorkingDirectory(path);
  ftp.storeFile(filename, input);
  input.close();
  ftp.logout();
  success = true;
 } catch (IOException e) {
  e.printStackTrace();
 } finally {
  if (ftp.isConnected()) {
   try {
    ftp.disconnect();
   } catch (IOException ioe) {
   }
  }
 }
 return success;
}
/**
 * 将本地文件上传到FTP服务器上 *
 * 
 *    int port,// FTP服务器端口
  String username, // FTP登录账号
  String password, // FTP登录密码
  String path, // FTP服务器保存目录
  String filename, // 上传到FTP服务器上的文件名
  String orginfilename // 输入流文件名
  
 */
public static void upLoadFromProduction(String url,int port,String username,String password,String path,String filename,String orginfilename) {
 try {
  FileInputStream in = new FileInputStream(new File(orginfilename));
  boolean flag = uploadFile(url, port,username, password, path,filename, in);
  System.out.println(flag);
 } catch (Exception e) {
  e.printStackTrace();
 }
}
 
 
public static void main(String[] args) {
 
upLoadFromProduction("127.40.1.80",21,"www", "huahua", "/ali/www/Cash/photo", "123.jpg", "C:/Users/Administrator/Desktop/11.jpg");
}
 






/**
 * Description: 向FTP服务器上传文件
 * @Version      1.0
 * @param url FTP服务器hostname
 * @param port  FTP服务器端口
 * @param username FTP登录账号
 * @param password  FTP登录密码
 * @param path  FTP服务器保存目录
 * @param filename  上传到FTP服务器上的文件名
 * @param input  输入流
 * @return 成功返回true,否则返回false *
 */
public static boolean uploadFile(String url,int port,String username,String password,String path,String filename,String customerNo,InputStream input){
 boolean success = false;
 FTPClient ftp = new FTPClient();
 ftp.setControlEncoding("GBK");
 try {
  int reply;
  ftp.connect(url,port);// 连接FTP服务器
  // 如果采用默认端口,可以使用ftp.connect(url)的方式直接连接FTP服务器
  ftp.login(username, password);// 登录
  reply = ftp.getReplyCode();
  if (!FTPReply.isPositiveCompletion(reply)) {
   ftp.disconnect();
   return success;
  }
//读取所有文件,根据文件名模糊删除远程照片
 FTPFile[] ftpFiles = null;
 ftpFiles = ftp.listFiles(path);
 for (int i = 0; ftpFiles != null && i < ftpFiles.length; i++) {
  FTPFile file = ftpFiles[i];
  if (file.isFile()) {
  if(file.getName().startsWith(customerNo)|| file.getName().endsWith(customerNo)){
  ftp.deleteFile(path+"/"+file.getName());
  }
  
  }
 }
  ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
  ftp.makeDirectory(path);
  ftp.changeWorkingDirectory(path);
  ftp.storeFile(filename, input);
  input.close();
  ftp.logout();
  success = true;
 } catch (IOException e) {
  e.printStackTrace();
 } finally {
  if (ftp.isConnected()) {
   try {
    ftp.disconnect();
   } catch (IOException ioe) {
   }
  }
 }
 return success;
}
posted @ 2015-03-12 18:13 藤本蔷薇 阅读(137) | 评论 (0)编辑 收藏

  1. 调用远程接口,返回的是http文件流,打开相关url,就可以直接下载txt文件,
    要对这相关的文件内容进行操作,不保存,可以调用下面这个方法直接读取文件流内容,测试了下,是可以的




    public
     String getYCFile(String urlPath) {  
  2.         String readStr = "";  
  3.         try {  
  4.             try {  
  5.                 String strUrl = urlPath.trim();  
  6.                 URL url = new URL(strUrl);  
  7.                 HttpURLConnection urlCon = (HttpURLConnection) url.openConnection();  
  8.                 urlCon.setConnectTimeout(10000);  
  9.                 urlCon.setReadTimeout(30000);  
  10.                 BufferedReader in = new BufferedReader(new InputStreamReader(  
  11.                         urlCon.getInputStream(), "GBK"));  
  12.                 String inputLine = " ";  
  13.                 while ((inputLine = in.readLine()) != null) {  
  14.                     readStr += inputLine.trim();  
  15.                 }  
  16.                 in.close();  
  17.                 return readStr;  
  18.             } catch (IOException e) {  
  19.                 readStr = "";  
  20.             }  
  21.         } catch (Exception e) {  
  22.             readStr = "";  
  23.         }  
  24.         return readStr;  
  25.     } 
posted @ 2015-03-06 15:40 藤本蔷薇 阅读(1064) | 评论 (0)编辑 收藏
 public static boolean delFilesByPath(String path,String str){
 //参数说明---------path:要删除的文件的文件夹的路径---------str:要匹配的字符串的头
 boolean b=false;
 File file = new File(path); 
 File[] tempFile = file.listFiles(); 
 for(int i = 0; i < tempFile.length; i++){ 
  if(tempFile[i].getName().startsWith(str)||tempFile[i].getName().endsWith(str)){ 
   tempFile[i].delete();
   b=true;
  }
 }
 return b;
}
 
public static void main(String[] args) {
 String path="F:/Installed---success---go/apache/webapps/images";
 String str="181";
 if(delFilesByPath(path,str)){
  System.out.println(path+"中包含"+str+"的文件已经全部删除成功!");
 }else{
  System.out.println(path+"中包含"+str+"的文件已经删除失败或该文件夹下不存在这类文件!");
 }
}
posted @ 2015-03-06 10:09 藤本蔷薇 阅读(165) | 评论 (0)编辑 收藏
posted @ 2015-02-10 13:50 藤本蔷薇 阅读(131) | 评论 (0)编辑 收藏

 Calendar.getInstance().get(Calendar.YEAR)
posted @ 2015-01-23 00:21 藤本蔷薇 阅读(138) | 评论 (0)编辑 收藏
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar c = Calendar.getInstance();
        c.add(Calendar.DAY_OF_MONTH, 1);
        System.out.println("增加一天后日期 : "+sf.format(c.getTime()));
posted @ 2015-01-21 15:26 藤本蔷薇 阅读(185) | 评论 (0)编辑 收藏
仅列出标题
共8页: 上一页 1 2 3 4 5 6 7 8 下一页