vendredi 20 novembre 2009

【转】Java » 文件输入输出 » 文件

1. 创建文件


2. 创建一个临时文件


3. 创建一个临时文件并删除它退出


4. 创建一个目录(或几个目录)


5. 获取文件大小


6. 变更文件或目录上次修改的时间


7. 构建文件路径


8. 创建临时文件指定的扩展名后缀


9. 创建临时文件中指定的目录


10. 创建新的空文件


11. 比较两个文件路径


12. 删除文件


13. 删除目录(空目录)


14. 删除文件或目录时,虚拟机终止


15. 确定文件或目录


16. 确定文件是否可以读取


17. 确定文件是否可以这样写:


18. 判断是否存在文件或目录


19. 确定文件或目录是隐藏


20. 证明文件


21. 移动文件或目录到另一个目录


22. 查找目录


23. 从java.io.File获得所有的路径信息


24. Getting an Absolute Filename Path from a Relative Filename Path


25. Getting an Absolute Filename Path from a Relative Filename with Path


26. Getting an Absolute Filename Path from a Relative Filename parent Path


27. 获得绝对文件的路径


28. 获取以字节为单位文件大小


29. 获取父目录的File对象


30. 取得文件最后修改日期


31. File.getCanonicalFile() converts a filename path to a unique canonical form suitable for comparisons.


32. Getting the Parents of a Filename Path


33. Get the parents of an absolute filename path


34. Getting and Setting the Modification Time of a File or Directory


35. 制作只读文件或目录


36. 文件根列表


37. 驱动器列表


38. 列出目录内容


39. 重命名文件或目录


40. 迫使更新一个文件到磁盘


41. 随机文件


42. 创建一个目录;所有祖先目录必须存在


43. Create a directory; all non-existent ancestor directories are automatically created


44. 获取当前的工作目录


45. 改变文件属性为可写


46. 数据文件


47. 输出到一个文本文件


48. 选择文件


49. 读取文本文件数据


50. 复制文件


51. 查询文件信息


52. Working with RandomAccessFile


53. 获取文件列表,并检查是否任何文件丢失


54. 从Java删除文件


55. Java中临时文件


56. 比较文件日期


57. 排序文件,基于他们的最后修改日期


58. 字符串-提取打印二进制文件字符串


59. 得到扩展名,路径和文件名


60. 读取文件内容字符串使用输入输出工具


61. Get all xml files by file extension


62. 文件名组件


63. 获取文件类型图标


64. 改变文件属性为只读


65. 获取文件扩展名


66. 递归的搜索文件


67. 创建一个人类可读的文件大小


68. 设置文件属性

mardi 17 novembre 2009

【转】有道搜索2010预览版问世

邀您试用“更宽的”搜索! 有道搜索2010预览版问世


代号“犇牛”的有道搜索2010预览版今天与您见面。自牛年春节后,有道的工程师们就已开始为这个全新的版本而努力,历经半年多的开发,有道搜索2010版在功能、速度和易用性上都有了进一步的提升。目前,我们会保持现有版本和预览版两套系统同时在线运行;如果您输入http://ox.youdao.com,就能访问到有道搜索2010预览版,还请先睹为快!
这一版本的主要功能有如下新增:
o 三栏宽幅的全新界面
o 尺度更宽的搜索选项
o 看得更多的网页预览
o 更为丰富的智能结果
o 一目了然的结构化摘要

lundi 16 novembre 2009

您在全球财富排名 上网查得到

据自由时报报导,想要知道自己的财富在全球排名第几吗?只要登入最近出现的一个新网站http://www.globalrichlist.com,将自己的年薪换算成美元或英镑,输入网页的问卷中,电脑就会告诉您排行世界富豪第几名。
这个网站是由伦敦一家互动媒体公司所设立,目的是要「挑战人们对其所拥有财富的认知」,因为每年进入全世界有钱人圈内的人口逐渐增加,而在人比人的竞争心理下,对自己财富排名好奇的人士也跟著增加。

世界富豪排名表的计算基础是引用世界银行发展研究小组的资料,其假设是全球总人口为六十亿人,平均年收入是五千美元。根据这项统计资料,全球每年九.五% 的总收入是由一%的人所赚走,他们的平均年收入是四万七千五百美元;全球财富排名前十%的人,赚走了全球五十.八%的年收入。至于全世界年收入最低的十% 人口,平均每日收入仅有一.一美元。

假设以台湾法定最低基本工资月薪一万五千八百四十元台币来计算,一年的年薪就是五千五百七十五美元,成为全球首富排行榜上第八亿三千三百一十三万六千二百四十七名,而且跻身进入了全球前十四%的有钱人圈子里。

[转] 自由撰稿人必须知道的15个在线资源

Freelancer往往不是那么容易当的,特别是自己刚起步的时候。在放弃工作将自己切换到自由工作者之前,最好能有一些客户和一些项目,有的时候你的 手头可能会忙不过来,所以就不得不做出正确的选择。今天我列出15个很棒的网站,可以让自由工作者(程序员、编码师、设计师)找到一些项目。
这些网站不会让你成为百万富翁,但是你能找到正经的工作,还能获得财富并且扩大投资组合。你只能通过获得一定数量的工作才能成为一位经验丰富的自由工作者,所以这些网站为你带来的不仅仅是财富。

99Designs BidHire CoderBuyer DesignQuote Elance GetACoder GetAFreelancer Guru LimeExchange PostBidWin PeoplePerHour Project4Hire ScriptLance Task City My Zoox

99Designs

99d

BidHire

bidhire

CoderBuyer

codeb

DesignQuote

desq

Elance

elance

GetACoder

geta

GetAFreelancer

getafree

Guru

guru

LimeExchange

lime

PostBidWin

postbid

PeoplePerHour

pph

Project4Hire

project

ScriptLance

scriptl

Task City

task

My Zoox

zoox

mardi 10 novembre 2009

Enable Apache installed in Mac OS X

If you’re running Mac OS X it has some surprises for you. Seems, PHP and the Apache Web Server have been installed on your machine without your knowledge. Well, its no secret but running them both is somewhat of a mystery and the trick is to flush them out of their hiding spots.

Generally on a Mac there are Icons that represent programs and documents that you double-click to execute their existence. With PHP and Apache, they run in the background with no sign of an Icon in sight.

To start Apache Web Server, you must go into the “System Preferences Control panel located on the “Apple Menu”.

Click on the Icon labeled "Sharing". Then locate the tab labeled "File & Web". You will want to click the button labeled “Start” in the "Web Sharing " section. This starts up Web sharing which starts the Apache Web Server.

Apache Web Server is now running. Easy, huh? "How can I tell?” you ask. Simple. Start up your web browser of choice. In the web address or URL part of your browser, type: "localhost" (without the double-quotes)

Ex.
http://localhost

If everything is Okay, your browser will display the following:

"If you can see this, it means that the installation of the Apache Web server software on this system was successful. You may now add content to this directory and replace this page."

It worked! Hooray.

To access the pages of this directory, double-click on your hard drive and locate the "Library" directory. From there locate the "WebServer" directory and then the "Documents" directory where these web pages reside.

Note: If its not running, you either do not have web sharing enabled or something is wrong with Apache's files. It should work right out of the box.

Since Mac OS X is a multi-user system, every person has their own account and with that brings it’s own set of web pages. To access your personal web pages you must type the following in the browser address:

Ex.
http://localhost/~yourname/

To access your personal web pages, locate your account name directory under "Users" And locate the directory labeled "Sites".

/Users/yourname/Sites/your web pages are here <---

Now that you have Apache running, it would be great to write your own PHP scripts and run them locally on your Mac. This is the most difficult part and if you get past this, everything is downhill with ease.

lundi 9 novembre 2009

Change default document root for Apache 2 in Ubuntu

The default document root for Apache 2 is "/var/www/", if you input "http://localhost/" in your Web browser's URL address, you will get the contents of "index.html" in "/var/www/" directory.

If you want to change this default directory, modify the file "/etc/apache2/sites-available/default" (sudo gedit /etc/apache2/sites-available/default), and then, use the following two commands:

sudo apache2ctl -t

And then

sud apache2ctl restart

ps: sometimes you need to restart your apache server, here is the commands:

sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 restart

jeudi 5 novembre 2009

An A-Z Index of the Apple OS X command line

An A-Z Index of the Apple OS X command line

a
alias Create an alias •
alloc List used and free memory
awk Find and Replace text within file(s)
b
basename Convert a full pathname to just a folder path
bash Bourne-Again SHell
bg Send to background •
bind Display readline key and function bindings •
bless Set volume bootability and startup disk options.
break Exit from a For, While, Until or Select loop •
builtin Execute a shell builtin •
bzip Compress or decompress files
c
cal Display a calendar
caller Return the context of a subroutine call •
case Conditionally perform a command •
cat Display the contents of a file
cd Change Directory •
chflags Change a file or folder's flags
chgrp Change group ownership
chmod Change access permissions
chown Change file owner and group
chroot Run a command with a different root directory
cksum Print CRC checksum and byte counts
clear Clear terminal screen
cmp Compare two files
comm Compare two sorted files line by line
command Run a command (not a function) •
complete Edit a command completion [word/pattern/list] •
continue Resume the next iteration of a loop •
cp Copy one or more files to another location
cron Daemon to execute scheduled commands
crontab Schedule a command to run at a later date/time
cut Divide a file into several parts
d
date Display or change the date & time
dc Desk Calculator
dd Data Dump - Convert and copy a file
declare Declare variable & set attributes •
defaults Set preferences, show hidden files
df Display free disk space
diff Display the differences between two files
diff3 Show differences among three files
dig DNS lookup
dirname Convert a full pathname to just a path
dirs Display list of remembered directories •
diskutil Disk utilities - Format, Verify, Repair
disown Unbind a job from the current login session •
ditto Copy files and folders
dot_clean Remove dot-underscore files
drutil Interact with CD/DVD burners
dscacheutil Query or flush the Directory Service/DNS cache
dscl Directory Service command line utility
du Estimate file space usage
e
echo Display message on screen •
ed A line-oriented text editor (edlin)
enable Enable and disable builtin shell commands •
env Set environment and run a utility
eval Evaluate several commands/arguments •
exec Execute a command •
exit Exit the shell •
expand Convert tabs to spaces
expect Programmed dialogue with interactive programs
Also see AppleScript
export Set an environment variable •
expr Evaluate expressions
f
false Do nothing, unsuccessfully
fc Fix command (history)
fdisk Partition table manipulator for Darwin UFS/HFS/DOS
fg Send job to foreground •
file Determine file type
find Search for files that meet a desired criteria
fmt Reformat paragraph text
fold Wrap text to fit a specified width
for Loop command •
fsck Filesystem consistency check and repair
fsaclctl Filesystem enable/disable ACL support
fs_usage Filesystem usage (process/pathname)
ftp Internet file transfer program
g
GetFileInfo Get attributes of HFS+ files
getopt Parse positional parameters
getopts Parse positional parameters •
goto Jump to label and continue execution
grep Search file(s) for lines that match a given pattern
groups Print group names a user is in
gzip Compress or decompress files
h
hash Refresh the cached/remembered location of commands •
head Display the first lines of a file
hdiutil Manipulate iso disk images
history Command History •
hostname Print or set system name
i
id Print user and group names/id's
if Conditionally perform a command •
info Help info
install Copy files and set attributes
j
jobs List active jobs •
join Join lines on a common field
k
kextfind List kernel extensions
kickstart Configure Apple Remote Desktop
kill Stop a process from running
l
l List files in long format (ls -l)
last Indicate last logins of users and ttys
launchctl Load or unload daemons/agents
ll List files in long format, showing invisible files (ls -la)
less Display output one screen at a time
let Evaluate expression •
lipo Convert a universal binary
ln Make links between files (hard links, symbolic links)
local Set a local (function) variable •
locate Find files
logname Print current login name
login log into the computer
logout Exit a login shell (bye) •
lpr Print files
lprm Remove jobs from the print queue
lpstat Printer status information
ls List information about file(s)
lsregister Reset the Launch Services database
lsbom List a bill of materials file
lsof List open files
m
man Help manual
mdfind Spotlight search
mdutil Manage Spotlight metadata store
mkdir Create new folder(s)
mkfifo Make FIFOs (named pipes)
more Display output one screen at a time
mount Mount a file system
mv Move or rename files or directories
n
net Manage network resources
netstat Show network status
networksetup Network and System Preferences
nice Set the priority of a command
nohup Run a command immune to hangups
ntfs.util NTFS file system utility
o
onintr Control the action of a shell interrupt
open Open a file/folder/URL/Application
osacompile Compile Applescript
osascript Execute AppleScript
p
passwd Modify a user password
paste Merge lines of files
pbcopy Copy data to the clipboard
pbpaste Paste data from the Clipboard
pico Simple text editor
ping Test a network connection
pkgutil Query and manipulate installed packages
plutil Property list utility
pmset Power Management settings
popd Restore the previous value of the current directory •
pr Convert text files for printing
printenv Print environment variables
printf Format and print data •
ps Process status
pushd Save and then change the current directory
pwd Print Working Directory •
q
quota Display disk usage and limits
r
rcp Copy files between machines
read Read one line from standard input •
readonly Mark a variable or function as read-only •
reboot Stop and restart the system
return Exit a function •
rev Reverse lines of a file
rm Remove files
rmdir Remove folder(s)
rpm Remote Package Manager
rsync Remote file copy - Sync file tree (also RsyncX)
s
say Convert text to audible speech
screen Multiplex terminal, run remote shells via ssh
screencapture Capture screen image to file or disk
sdiff Merge two files interactively
security Administer Keychains, keys, certificates and the Security framework
sed Stream Editor
select Generate a list of items •
set Set a shell variable = value •
setfile Set attributes of HFS+ files
shift Shift positional parameters •
shopt Set shell options •
shutdown Shutdown or restart OS X
sleep Delay for a specified time
softwareupdate System software update tool
sort Sort text files
source Execute commands from a file •
split Split a file into fixed-size pieces
stop Stop a job or process
su Substitute user identity
sudo Execute a command as another user
sum Print a checksum for a file
suspend Suspend execution of this shell •
sw_vers Print Mac OS X operating system version
system_profiler Report system configuration
systemsetup Computer and display system settings
t
tail Output the last part of files
tar Tape ARchiver
tee Redirect output to multiple files
test Condition evaluation •
textutil Manipulate text files in various formats (Doc,html,rtf)
time Measure Program Resource Use
times Print shell & shell process times •
touch Change file timestamps
tr Translate, squeeze, and/or delete characters
trap Execute a command when the shell receives a signal •
traceroute Trace Route to Host
true Do nothing, successfully
tty Print filename of terminal on stdin
type Describe a command •
u
ufs.util Mount/unmount UFS file system
ulimit limit the use of system-wide resources •
umask Users file creation mask
umount Unmount a device
unalias Remove an alias •
uname Print system information
unexpand Convert spaces to tabs
uniq Uniquify files
units Convert units from one scale to another
unset Remove variable or function names •
until Loop command •
users Print login names of users currently logged in
uuencode Encode a binary file
uudecode Decode a file created by uuencode
uuidgen Generate a Unique ID (UUID/GUID)
uucp Unix to Unix copy
v
vi Text Editor
w
wait Wait for a process to complete •
wc Print byte, word, and line counts
where Report all known instances of a command
which Locate a program file in the user's path
while Loop command •
who Print all usernames currently logged on
whoami Print the current user id and name (`id -un')
write Send a message to another user
x
xargs Execute utility - passing arguments
yes Print a string until interrupted

Commands marked • are bash built-in commands.
OS X Panther 10.3, Tiger 10.4 and Leopard 10.5 default to running the bash shell, this runs under 'Darwin' the open source core of OSX.

OS X Man Pages - Apple Developer Connection
Discussion forum
Links to other Sites, Books etc...

Mac OS X is a rock-solid system that's beautifully designed. I much prefer it to Linux - Bill Joy

lundi 2 novembre 2009

经济学原理——2009.11.2 学习笔记

经济来源于希腊语 oikonomos, 原意是管理一个家庭的人。 类比:家庭分工 社会分工。
稀缺性:社会资源有限,管理十分重要。经济学研究如何管理自己的稀缺资源(时间?)

本章讲述经济学的十大原理:

1.1: 如何决策
------------
原理1: 人们面临权衡取舍
天下没有免费的午餐——如何取舍,放弃些什么,追求些什么。
支配时间,支配收入。
环保-》污染管制-》利润下降-》收入减少。(环保 利益)
平等-》税收-》高收入-》高税收-》平等打破了效率。

原理2: 某种东西的成本是为了得到他所放弃的东西
利益与成本,大学: 利益-》丰富了知识
成本-》时间(这些时间可以用来工作=收入)
机会成本(opportunity cost): 是为了得到这种东西所放弃的东西。
大学球员:进入NBA or 再在大学打一年?

原理2:理性人考虑边际量
经济学家通常假设:人是理性的。
理性人(rational people):尽最大努力去实现自己的目标。
决策很少是黑与白的选择,而是在两者之间——边际变动(marginal change)。
理性人通过比较边际利益(marginal benefit)与边际成本(marginal cost)来做出决定。
ex: 飞机一趟旅行10w 么元,200个座位,每人应该500美元;如果有10个空位,飞机起飞前可以以300美元出售票价,因为此时的边际成本很小。
边际决策解释另外一个现象:水便宜,钻石贵。和钻石相比,水是不可或缺的。why?因为水太多了=边际利益微不足道。
正确理解边际利益和边际成本。

原理4: 人们会对激励作出反应
激励(incentive),在经济学中,激励起着中心作用。
有人这样定义经济学:人们对激励作出的反应,其余内容都是对此的解释。
价格对消费者和生产者行为的激励。
许多政策改变了人们面临的成本或利益。ex: 汽油税-》开小型车,拼车,公交车
安全带:减少了每次车祸的死亡人数,却增加了车祸的数量。-》司机的死亡几率减小,行人几率增大。
政策:激励作用。
激励型工资-》更有效率。

※即问即答:
1:权衡取舍:找工作 & 读博士
2:
3:SONY MD Player

1.2: 人们如何相互交易
--------------
原理5: 贸易可以使每个人的状况都变得更好
美国和日本经济的竞争:会使两国都变得更好。
相互交易使交易双方获益。

原理6: 市场通常是组织经济活动的一种好方法
计划经济-》市场经济。
亚当.斯密:看不见的手:价格会自动调整。-》税收扭曲了价格,也扭曲了家庭和企业的决策。计划经济之所以失败,是因为他们吧这只看不见的手绑起来了。
每个人所做的经济决策,全部都是基于他自己的利益-》经济的参与者大都是受利己心的驱动,受到“看不见的手”的指引,促进总体的经济福利。

原理7: 政府有时可以改善市场结果
为什么需要政府?政府用来实施规则并维持对市场经济至关重要的制度,只有这样,“看不见的手”才能发挥作用。
因为市场经济需要实施产权制度,以使个人能够占有稀缺资源。
ex: 只有确保了顾客在离开前会付费,餐馆才会提供服务。
政府干预:促进平等与效率。
“看不见的手”: 市场失灵(market failure)-》垄断。
政策: 什么时候使正确的?

※即问即答
1:一个国家闭关,无竞争,市场无生气
2:有市场因为有供求关系。政府宏观调控。

1.3: 整体经济如何运行
--------------
原理8: 一国的生活水平取决于他的生产物品与劳务的能力
各国的生活水平不同-》生产率(productivity)不同
提高生活水平,决策者-》工人收到良好的教育,拥有生产物频域先进的生产工具,最好的技术。

原理9: 当政府发行了过多的货币时,物价上升
通货膨胀(inflation)每年的增长率为2.5%,物价每30年翻一番。(与收入的增长率差不多?)

原理10: 社会面临通货膨胀与失业之间的短期权衡取舍
通货膨胀-》支出水平高-》雇佣更多的工人-》更少的人失业

※即问即答
三个原理:
1:生产率决定生活水平
2:货币发行过多引起通货膨胀
3:通货膨胀能提高就业率

1.4: 结论
---------------
回忆经济学十大原理
1:决策
2:理智
3:激励
4:通货膨胀-》就业
5:市场经济
6:货币过多-》通货膨胀

7:某种东西的成本是为了得到他所放弃的东西
8:贸易可以让双边都更好
9:政府可以适当干预
10:国家的生活水平取决于生产率

100 Free Applications for Mac OS X

http://www.usingmac.com/2008/11/12/100-free-applications

[Tips]快速获知文件类型- Mac OS X

有的时候碰上没见过的文件扩展名,有些朋友就手忙脚乱了,不知道该用什么软件打开文件。
有的朋友选择去google,这未尝不可,不过有时扩展名什么都说明不了,文件的真正类型有时可能和扩展名无关。

那么如何了解一个文件的类型呢?我们需要用到UNIX命令----> file。
这个命令读取文件头,返回文件类型,使用方法也相当简单。打开终端(“应用程序” > “实用程序” > “终端”),输入file和空格,不回车,把想探测的文件拖入终端窗口,回车即可 (或者直接输入文件的路径名)。

这个命令不仅可以用来获知文件类型,还有一个很实用的用途是获知Universal程序所包含的代码类型,需要注意的是,使用的时候不要将程序app拖进终端,而是要通过Show Package Contents来进入app包的内部,然后进入MacOS文件夹,找到真正的程序文件。