Tuesday, January 29, 2008

java读取utf-8编码文件

发觉直接读中文会出现乱码,所以要这样:
BufferedReader br=new BufferedReader(new InputStreamReader (new FileInputStream(new File("utf-8.txt")),"UTF-8"));

Sunday, January 27, 2008

Ruby

很早就听说Ruby,但从没去看过和碰过。到http://www.ruby-lang.org/ 看了下,挺有意思的。在gentoo上装了一个准备玩玩。

Wednesday, January 16, 2008

溜车事故

没有偶然的交通事故,只有偶然的侥幸。今天下班从沪青平上外环开始就一直堵啊堵,到吴中路出口那的一个坡道上时又堵死了!

爸爸说上坡如果熟练的话就不用拉手刹,我也屡试不爽,不过也熄过好几次火,但都被我眼明手快手刹拉住了。不知道这几天怎么回事,难道是天冷脚僵了?我左脚始终把握不好半离合的位子,导致坡道上第一次起步熄火,立马踩住刹车启动车子,这次离合又放太慢,右脚空踩了下油门,砰~~!一声,溜车碰到后面的车了。其实速度很慢,我才溜了一米吧,于是下车和后车司机打招呼。

印象当中我碰到过2次轻微追尾,反正出租车司机而且是上海人的都很客气,看到自己车没什么大事也就关照你一下就走人了。这次不同了,那白痴看我下车,立马开门冲我大喊大叫,反正我上前就问了下是否准备私了。那外地人就跑到自己车里往后倒了一点,然后跑到自己车头一会说这坏了,一会又说那个前进气栅格坏了,里面的卡口全断了,而且还说什么前保险杠断了。去他妈妈的,不是他不诚实就是奇瑞汽车烂(我相信前者),就轻微碰了下保险杠就断了?比小日本在中国造的蛋壳车还吸能嘛,可笑,一看就知道都是他以前自己弄断了来走保险,正巧被我碰上。

其实这白痴就前保险杠掉了点漆,我的车似乎连漆都没掉,准备200RMB私了,那白痴死活不肯,没办法,110之,双方协调我出500走保险,他居然说NO,册那,则戆比样!因为警察的 权利是1000RMB,所以他起初硬是要1000RMB,。只能说大多数素质低下的外地人损坏了 所有外地人的名声,这跟中国那些去国外混的败类没什么不同。最终走保险,他硬是敲诈了我700RMB,钱到没什么,反正保险,主要是那种不诚实加上无赖,低劣的素质。

更妖的是一开始警察叔叔说要扣车,我的神啊,警察叔叔发疯了,为了年终奖,竟然干这些苛扣良民的事情,他的理由听起来有点道理,说是因为小碰撞没有立刻撤离现场,造成交通拥堵。但仔细想想,我就是因为堵车所以才没离开现场的啊,扣他个鬼啊~!幸好警察叔叔还是有点正义感的,所以最终我还是开着车安全到家。

到家后反思了一下,自己的确是车技不过关,人家老驾驶员不用手刹,我只不过4个月的新手,这样做的确是必然导致交通事故。之前没有溜车都是因为坡度都比较缓,而且大多都是1档2档慢速上坡,上周日有一个大陡坡我就溜车差点碰到后车,今天是没这个运气了。

第二点,周围的人都说安徽人很坏,今天终于见识过安徽人中的低素质者了。谁都知道其实安徽人不全坏,但坏的被我碰到了。所以大家开车要注意分清前后左右车都是些什么车主,以免发生碰撞时小事变大,大事更大!

Wednesday, January 9, 2008

wii游戏复制成功

用alcohol 120%把盗版盘的内容抓取出来,然后用alcohol 120%进行刻录,刻的时候选了最低的2.5X,刻录盘为Verbatim的+R盘,刻录光驱是gateway的laptop自带的,型号没具体看。

刻完放入WII,发现果然比盗版盘的声音小很多,认盘很快,读盘很顺畅。而且盗版盘有时玩着玩着会读不出,现在玩起来绝对没有读不出盘的问题。果然WII的游戏如果买的是盗版盘还是刻盘玩比较好啊,玩得爽对WII光驱也有好处,咔咔~~!

Tuesday, January 8, 2008

spring的Message Driven POJO (MDP)

发现SPRING的MDP很好用。不需要像MDB那么麻烦。
首先只要创建一个实现了MessageListener的POJO。
package test;

import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

public class MDPTest implements MessageListener {



public void onMessage(Message message) {
        if (message instanceof MapMessage) {
                MapMessage mapMsg = (MapMessage) message;

                String title;
                try {
                        title = mapMsg.getString("title");

                        System.out.println("Received: " + title);
                        System.out.println("               " + mapMsg.getString("type"));
                        System.out.println("               " + mapMsg.getString("body"));

                        System.out.println("Received: " + message);
                } catch (JMSException e) {
                        e.printStackTrace();
                }

        }
}
}
然后就是在SPRING里配置MDP所需的BEAN,一个最常用的DefaultMessageListenerContainer即可。
<!--xml version="1.0" encoding="UTF-8"?-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<!-- Message Driven POJO (MDP) -->
<bean id="messageListener" class="test.MDPTest" />

<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://192.168.24.194:11111"/>
</bean>

<bean id="destination" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg index="0" value="IN"/>
</bean>

<!-- message listener container -->
<bean id="jmsContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory" />
<property name="destination" ref="destination" />
<property name="messageListener" ref="messageListener" />
</bean>
</beans>
之后只需把ACTIVEMQ配置好启动起来就OK了。当有消息进入IN这个队列时,SPRING会自动INVOKE我们的MDP。

Friday, January 4, 2008

Wednesday, January 2, 2008

RAW FTP Commands

from http://www.jtpfxp.net/rawcmd.htm
RAW FTP Commands


Updated: 01-03-02
by DreamHaven
Introduction
Common Commands
Uncommon Commands
Descriptions

Introduction

If you need to do something on a ftp but the ftp client wont do what you want its easy to enter the commands manually. Just find the RAW Commands option on your ftp client (Command -> RAW Commands in FlashFXP) and put in whatever you want. Most of the information here was taken from various sources and of course I reformatted it to make it easier to get around. Mostly taken from: http://www.dreamhaven.org/ftp-raw.html

* Most FTP Servers do not support this command

Common Commands
ABOR - abort a file transfer
CWD - change working directory
DELE - delete a remote file
LIST - list remote files
MDTM - return the modification time of a file
MKD - make a remote directory
NLST - name list of remote directory
PASS - send password
PASV - enter passive mode
PORT - open a data port
PWD - print working directory
QUIT - terminate the connection
RETR - retrieve a remote file
RMD - remove a remote directory
RNFR - rename from
RNTO - rename to
SITE - site-specific commands
SIZE - return the size of a file
STOR - store a file on the remote host
TYPE - set transfer type
USER - send username

Uncommon Commands
ACCT* - send account information
APPE - append to a remote file
CDUP - CWD to the parent of the current directory
HELP - return help on using the server
MODE - set transfer mode
NOOP - do nothing
REIN* - reinitialize the connection
STAT - return server status
STOU - store a file uniquely
STRU - set file transfer structure
SYST - return system type

Descriptions

ABOR
Syntax: ABOR
Aborts a file transfer currently in progress.

ACCT*
Syntax: ACCT account-info
This command is used to send account information on systems that require it. Typically sent after a PASS command.

ALLO
Syntax: ALLO size [R max-record-size]
Allocates sufficient storage space to receive a file. If the maximum size of a record also needs to be known, that is sent as a second numeric parameter following a space, the capital letter "R", and another space.

APPE
Syntax: APPE remote-filename
Append data to the end of a file on the remote host. If the file does not already exist, it is created. This command must be preceded by a PORT or PASV command so that the server knows where to receive data from.

CDUP
Syntax: CDUP
Makes the parent of the current directory be the current directory.

CWD
Syntax: CWD remote-directory
Makes the given directory be the current directory on the remote host.

DELE
Syntax: DELE remote-filename
Deletes the given file on the remote host.

HELP
Syntax: HELP [command]
If a command is given, returns help on that command; otherwise, returns general help for the FTP server (usually a list of supported commands).

LIST
Syntax: LIST [remote-filespec]
If remote-filespec refers to a file, sends information about that file. If remote-filespec refers to a directory, sends information about each file in that directory. remote-filespec defaults to the current directory. This command must be preceded by a PORT or PASV command.

MDTM
Syntax: MDTM remote-filename
Returns the last-modified time of the given file on the remote host in the format "YYYYMMDDhhmmss": YYYY is the four-digit year, MM is the month from 01 to 12, DD is the day of the month from 01 to 31, hh is the hour from 00 to 23, mm is the minute from 00 to 59, and ss is the second from 00 to 59.

MKD
Syntax: MKD remote-directory
Creates the named directory on the remote host.

MODE
Syntax: MODE mode-character

Sets the transfer mode to one of:
S - Stream
B - Block
C - Compressed

The default mode is Stream.

NLST
Syntax: NLST [remote-directory]
Returns a list of filenames in the given directory (defaulting to the current directory), with no other information. Must be preceded by a PORT or PASV command.

NOOP
Syntax: NOOP
Does nothing except return a response.

PASS
Syntax: PASS password
After sending the USER command, send this command to complete the login process. (Note, however, that an ACCT command may have to be used on some systems.)

PASV
Syntax: PASV
Tells the server to enter "passive mode". In passive mode, the server will wait for the client to establish a connection with it rather than attempting to connect to a client-specified port. The server will respond with the address of the port it is listening on, with a message like:
227 Entering Passive Mode (a1,a2,a3,a4,p1,p2)
where a1.a2.a3.a4 is the IP address and p1*256+p2 is the port number.

PORT
Syntax: PORT a1,a2,a3,a4,p1,p2
Specifies the host and port to which the server should connect for the next file transfer. This is interpreted as IP address a1.a2.a3.a4, port p1*256+p2.

PWD
Syntax: PWD
Returns the name of the current directory on the remote host.

QUIT
Syntax: QUIT
Terminates the command connection.

REIN*
Syntax: REIN
Reinitializes the command connection - cancels the current user/password/account information. Should be followed by a USER command for another login.

REST
Syntax: REST position
Sets the point at which a file transfer should start; useful for resuming interrupted transfers. For nonstructured files, this is simply a decimal number. This command must immediately precede a data transfer command (RETR or STOR only); i.e. it must come after any PORT or PASV command.

RETR
Syntax: RETR remote-filename
Begins transmission of a file from the remote host. Must be preceded by either a PORT command or a PASV command to indicate where the server should send data.

RMD
Syntax: RMD remote-directory
Deletes the named directory on the remote host.

RNFR
Syntax: RNFR from-filename
Used when renaming a file. Use this command to specify the file to be renamed; follow it with an RNTO command to specify the new name for the file.

RNTO
Syntax: RNTO to-filename
Used when renaming a file. After sending an RNFR command to specify the file to rename, send this command to specify the new name for the file.

SITE*
Syntax: SITE site-specific-command
Executes a site-specific command.

SIZE
Syntax: SIZE remote-filename
Returns the size of the remote file as a decimal number.

STAT
Syntax: STAT [remote-filespec]
If invoked without parameters, returns general status information about the FTP server process. If a parameter is given, acts like the LIST command, except that data is sent over the control connection (no PORT or PASV command is required).

STOR
Syntax: STOR remote-filename
Begins transmission of a file to the remote site. Must be preceded by either a PORT command or a PASV command so the server knows where to accept data from.

STOU
Syntax: STOU
Begins transmission of a file to the remote site; the remote filename will be unique in the current directory. The response from the server will include the filename.

STRU
Syntax: STRU structure-character

Sets the file structure for transfer to one of:
F - File (no structure)
R - Record structure
P - Page structure

The default structure is File.

SYST
Syntax: SYST
Returns a word identifying the system, the word "Type:", and the default transfer type (as would be set by the TYPE command). For example: UNIX Type: L8

TYPE
Syntax: TYPE type-character [second-type-character]

Sets the type of file to be transferred. type-character can be any of:
A - ASCII text
E - EBCDIC text
I - image (binary data)
L - local format

For A and E, the second-type-character specifies how the text should be interpreted. It can be:
N - Non-print (not destined for printing). This is the default if second-type-character is omitted.
T - Telnet format control (, , etc.)
C - ASA Carriage Control

For L, the second-type-character specifies the number of bits per byte on the local system, and may not be omitted.

USER
Syntax: USER username
Send this command to begin the login process. username should be a valid username on the system, or "anonymous" to initiate an anonymous login.