您的位置:首页 > 其它

第九篇

2016-01-25 09:57 253 查看
linux抓包:

tcpdump -i wlp8s0  -s 0 -w update2.pcap host push.baidu.com

-s 0 : 抓取数据包时默认抓取长度为68字节。加上-S 0 后能够抓到完整的数据包

-w  update.cap : 保存成cap文件

java:接口

一个接口可以有多个直接父接口,但接口只能继承接口,不能继承类

接口里可以包含属性(只能是常量)、方法(只能是抽象实例方法)、内部类(包括内部接口)和枚举类定义

在接口中定义属性时,不管是否使用public  static final 修饰符,接口里的属性总将使用这三个修饰符来修饰,在定义时指定默认值

nodejs:

Buffer对象可以和字符串相互转换,支持的编码类型如下:

ASCII、UTF-8、UTF-16LE/UCS-2、Base64、Binary、Hex(不支持gbk)

path.resolve([from ...], to)

把to 解析为一个绝对路径。

如果to不是一个相对于from 参数的绝对路径,to会被添加到from的右边,直到找出一个绝对路径为止。如果使用from路径且仍没有找到绝对路径时,使用当时路径作为目录。返回的结果已经规范化,得到的路径会去掉结尾的斜杠,除非得到的当前路径为root目录。非字符串参数将被忽略

var path = require('path');
router.get('/testpath', function(req, res, next) {
//返回路径中的最后哦一部分. 类似于Unix 的 basename 命令
var basename1=path.basename('/usr/source/wiseapp/views/test.html');//获取 test.html
console.log("basename1 "+basename1);
var basename2=path.basename('/usr/source/wiseapp/views/test.html','.html');//获取test
console.log("basename2 "+basename2);

//返回路径中文件夹的名称. 类似于Unix的dirname 命令
var filedirname=path.dirname("usr/source/wiseapp/views/test");//usr/source/wiseapp/views
console.log("filedirname "+filedirname);
//返回路径中文件的扩展名, 在从最后一部分中的最后一个'.'到字符串的末尾。 如果在路径的最后一部分没有'.',或者第一个字符是'.',就返回一个 空字符串
console.log(path.extname('index.html'));//.html
console.log(path.extname('index.test.md'));//.md
console.log(path.extname('index.'));//.
console.log(path.extname('index'));//空字符串
console.log(path.extname('.index'));//空字符串
//path.join() 连接所有参数, 并且规范化得到的路径,参数必须是是字符串
console.log(path.join('/foo', 'bar', 'baz//asdf/dd', 'dquux', '..'));///foo/bar/baz/asdf/dd???????
//判定path是否为绝对路径
console.log("是否是绝对路径 "+path.isAbsolute("/usr/local")); //true
console.log(path.resolve('foo/bar', 'tmp/file/',  'new.xml')); // /usr/testmdp/appwise/bin/foo/bar/tmp/file/new.xml
//破解从from到to的相对路径  有时我们有2个绝对路径, 我们需要从中找出相对目录的起源目录。这完全是path.resolve的相反实现
console.log(path.relative("/usr/local/test/aa","/usr/dd/mdp/ff")); //    ../../mdp/ff
res.send("dddd");

});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: