posts - 15,comments - 0,trackbacks - 0
这里所说的不是驱动对象,而是这个内核模块在内核内存空间中的地址。这是一个常用的技巧:在驱动对象中DriverStart域和DriverSize域分别记载着这个驱动对象所代表的内核模块在内核空间中的开始地址和大小。
posted @ 2012-11-12 19:06 aya000 阅读(205) | 评论 (0)编辑 收藏
error LNK2019: unresolved external symbol _RtlStringVPrintfWorkerW@20 referenced in function _RtlStringCchPrintfW
error LNK2019: unresolved external symbol _RtlStringValidateDestW@12 referenced in function _RtlStringCchPrintfW
sources文件加入库文件
TARGETLIBS= $(DDK_LIB_PATH)\ntstrsafe.lib
原文:http://blog.csdn.net/iamoyjj/archive/2011/02/01/6171792.aspx
posted @ 2012-11-11 17:30 aya000 阅读(646) | 评论 (0)编辑 收藏
1>避免创建不必要的对象
2>如果方法用不到成员变量,可以把方法声明为static,性能会提高15%到20%
3>避免使用getters/setters存取Field,可以把Field声明为public,直接访问
4>static的变量如果不需要修改,应使用static final 修饰符定义为常量
5>使用增强for循环语法——for(:)
6>私有内布类要访问外部类的Field或方法,可以把外部类的Field或方法声明为包访问权限
7>合理使用浮点数,浮点数比整型慢两倍
posted @ 2012-11-03 22:30 aya000 阅读(228) | 评论 (0)编辑 收藏
这大概是由xml文件中的编码规则决定要这么变换。
在xml文件中有以下几类字符要进行转义替换:

<

<

小于号

&gt;

>

大于号

&amp;

&

&apos;

'

单引号

&quot;

"

双引号


posted @ 2012-10-28 00:11 aya000 阅读(421) | 评论 (0)编辑 收藏
(function(){     
    if(!/*@cc_on!@*/0)
    return;
    var e = "abbr,article,aside,audio,bb,canvas,datagrid,datalist,details,dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','),i=e.length;
    while(i--){document.createElement(e[i])}
})()
//然后在head中引入该js
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js">
</script>
<![endif]-->
posted @ 2012-08-16 15:03 aya000 阅读(188) | 评论 (0)编辑 收藏
        .
        .
        .
         //改变状态
        this.addEventListener(MouseEvent.DOUBLE_CLICK,changeImg);
        .   
        .
        .
//改变
public function changeImg():void {
    arguments; //如果方法没有参数,则必须在方法中添加这个声明
    if(this.source == img0) {
        this.source = img1;
    } else {
            this.source = img0;
      }
        }
posted @ 2012-04-15 12:20 aya000 阅读(1440) | 评论 (0)编辑 收藏
  请求登录人人网比较麻烦,需要记住cookie,尤其是这句代码,
httpContext.setAttribute(ClientContext.COOKIE_STORE,httpClient.getParams().getParameter("CookieStore"));
试了很多遍才找到httpClient.getParams().getParameter("CookieStore"))。

主要代码如下:

package com.koyo.downloadphoto.service.impl;

import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.htmlparser.Parser;
import org.htmlparser.filters.AndFilter;
import org.htmlparser.filters.HasAttributeFilter;
import org.htmlparser.filters.TagNameFilter;
import org.htmlparser.tags.ImageTag;
import org.htmlparser.tags.LinkTag;
import org.htmlparser.tags.Span;
import org.htmlparser.util.NodeList;

import com.koyo.downloadphoto.service.Spider;
import com.koyo.downloadphoto.utils.HttpUtils;
import com.koyo.downloadphoto.utils.ParseUtils;

public class SpiderForRenRen extends Spider {

 private Logger logger = Logger.getLogger(SpiderForRenRen.class);

 @Override
 public void execute() {

  try {

   String url = "http://photo.renren.com/photo/" + friendId
     + "/album/relatives";

   // ===================请求登录======================================================
   HttpPost post = new HttpPost("http://www.renren.com/PLogin.do");
   // 添加POST参数
   List<NameValuePair> nvps = new ArrayList<NameValuePair>();
   nvps.add(new BasicNameValuePair("email", loginName));
   nvps.add(new BasicNameValuePair("password", loginPassword));
   post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
   HttpResponse response = httpClient.execute(post, httpContext);

   HttpEntity entity = response.getEntity();
   if (entity != null) {
    InputStream is = entity.getContent();
    // 使用响应中的编码来解释响应的内容
    String html1 = IOUtils.toString(is);
    LinkTag linkTag1 = ParseUtils.parseTag(html1, LinkTag.class);
    String url1 = linkTag1.getLink();

    HttpGet get = new HttpGet(url1);
    response = httpClient.execute(get, httpContext);
    // 保存cookie
    httpContext.setAttribute(ClientContext.COOKIE_STORE, httpClient
      .getParams().getParameter("CookieStore"));
    EntityUtils.consume(response.getEntity());
    
    System.out.println("账号:" + loginName);
    System.out.println("密码:" + loginPassword);
   }
   // ===================获取相册页面信息===================================================
   // 根据URL地址,获取网页内容
   String html = HttpUtils.getHtml(httpClient, httpContext, url);

   if (html == null) {
    logger.error("无法获取【" + url + "】网址的内容");
    throw new RuntimeException("无法获取【" + url + "】网址的内容");
   }
   
   //获取好友名
   Parser parser = new Parser();
   parser.setInputHTML(html);
   AndFilter andFilter = new AndFilter(new TagNameFilter("ul"), new HasAttributeFilter("class", "nav-tabs"));
   NodeList nodes = parser.parse(andFilter);
   String tempString = nodes.toHtml();
   LinkTag tempTag = ParseUtils.parseTag(tempString, LinkTag.class);
   String tempName = tempTag.getLinkText();
//   String friendName = tempName.substring(tempName.indexOf("\n")+1,tempName.lastIndexOf("\n"));
   String friendName = tempName.trim();
   
   //获取相册名
   String albumName;
   
   List<LinkTag> linkTags = ParseUtils.parseTags(html, LinkTag.class,
     "class", "album-cover");
   List<Span> spans = ParseUtils.parseTags(html, Span.class,"class","album-name");

   if (linkTags != null) {
    for (int i=0; i<linkTags.size(); i++) {
     tempName = spans.get(i).getStringText();
     //由于头像相册前还有一个<span class="userhead"/>  故不能使用tempName.trim()
     albumName = tempName.substring(tempName.lastIndexOf("\n")+1);
     url = linkTags.get(i).getLink();
     // 根据URL地址,获取网页内容
     html = HttpUtils.getHtml(httpClient, httpContext, url);

     if (html == null) {
      logger.error("无法获取【" + url + "】网址的内容");
      throw new RuntimeException("无法获取【" + url + "】网址的内容");
     }

     List<LinkTag> linkTags2 = ParseUtils.parseTags(html,
       LinkTag.class, "class", "picture");
     if (linkTags2 != null) {
      for (LinkTag linkTag2 : linkTags2) {
       url = linkTag2.getLink();
       // 根据URL地址,获取网页内容
       html = HttpUtils.getHtml(httpClient, httpContext,
         url);

       if (html == null) {
        logger.error("无法获取【" + url + "】网址的内容");
        throw new RuntimeException("无法获取【" + url
          + "】网址的内容");
       }

       // 网页中所包含的图片,并下载到upload目录,然后创建Attachment对象
       ImageTag imageTag = ParseUtils.parseTag(html,
         ImageTag.class, "id", "photo");
       if (imageTag != null) {

        // 得到图片所在的路径目录
        // String baseUrl = url.substring(0,
        // url.lastIndexOf("/") + 1);

        // 这个是<img>标签中的src的值
        String imageUrl = imageTag.getImageURL();
        String photoName = imageUrl.substring(imageUrl
          .lastIndexOf("/"));
        // 图片的绝对路径
        // String absoluteUrl = baseUrl + imageUrl;

        // : "文章标题/xxx.jpg"
        String imageName = friendName + "/" +albumName + photoName;

        // 把图片保存到upload目录
        // 首先确定,保存到本地的图片的路径
        String imageLocalFile = "D:/PhotosForRenRen/"
          + imageName;

        // 如果图片已经被下载到本地,则不再下载
        if (!new File(imageLocalFile).exists()) {
         // 下载图片的信息
         byte[] image = HttpUtils.getImage(
           httpClient, httpContext, imageUrl);
         // 直接使用new
         // FileOutputStream(imageLocalFile)这种方式,创建一个
         // 文件输出流,存在的问题就是:如果这个文件所在的目录不存在,则创建不了
         // 输出流,会抛出异常!
         // 所以,使用辅助的工具类来创建一个文件输出流:FileUtils.openOutputStream(new
         // File(imageLocalFile))
         // 通过这个方法,当文件所在的父目录不存在的时候,将自动创建其所有的父目录
         IOUtils.write(image, FileUtils
           .openOutputStream(new File(
             imageLocalFile)));
         System.out.println("图片【" + imageUrl
           + "】已下载");
        }
       }
      }
     }
    }
   }

  } catch (Exception e) {
   e.printStackTrace();
  }

 }
}

posted @ 2012-02-23 13:42 aya000 阅读(471) | 评论 (0)编辑 收藏
applicationContext.xml配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config/>
<context:component-scan base-package="com.koyo"/>
</beans>
posted @ 2011-12-01 21:01 aya000 阅读(1052) | 评论 (0)编辑 收藏
public void SetValue(Object obj, String fieldName, Object value)
throws SecurityException, NoSuchFieldException,
NoSuchMethodException, IllegalArgumentException,
IllegalAccessException, InvocationTargetException {
String firstLetter = fieldName.substring(0, 1).toUpperCase();
String setMethodName = "set" + firstLetter + fieldName.substring(1);
Field field = obj.getClass().getDeclaredField(fieldName);
Method setMethod = obj.getClass().getDeclaredMethod(setMethodName,
field.getType());
setMethod.invoke(obj, value);
}
posted @ 2011-10-16 21:46 aya000 阅读(1300) | 评论 (0)编辑 收藏
遇到这种问题,请参照这种写法:
s|Application
{               
    fontFamily:"Georgia";
    color:#000000;
}
posted @ 2011-08-30 16:42 aya000 阅读(718) | 评论 (0)编辑 收藏
仅列出标题  下一页