外文翻译---Java核心技术 卷Ⅱ高级特性

外文翻译---Java核心技术 卷Ⅱ高级特性
外文翻译---Java核心技术 卷Ⅱ高级特性

附录4 外文翻译

Java核心技术卷Ⅱ高级特性

当Java技术刚刚问世时,令人激动的并不是因为它是一个设计完美的编程语言,而是因为它能够安全地运行通过因特网传播的各种applet。很显然,只有当用户确信applet的代码不会破坏他的计算机时,用户才会接受在网上传播的可执行的applet。正因为如此,无论过去还是现在,安全都是设计人员和Java技术使用者所关心的一个重大问题。这就意味着,Java技术与其他的语言和系统有所不同,在那些语言和系统中安全是事后才想到要去实现的,或者仅仅是对破坏的一种应对措施,而对Java技术来说,安全机制是一个不可分割的组成部分。

Java技术提供了以下三种确保安全的机制:

(1)语言设计特性(对数组的边界进行检查,无不检查类型的转换,无指针算法等)。

(2)访问控制机制,用于控制代码能够执行的功能(比如文件访问,网络访问等)。

(3) 代码签名,利用该特性,代码的作者就能够用标准的加密算法来表明Java代码的身份。这样,该代码的使用者就能够准确地知道谁创建了该代码,以及代码被标识后是否被修改过。

下面,我们要介绍java.security包提供的加密算法,用来进行代码的标识和用户身份认证。

正如我们前面所说,applet 是在Java平台上开始流行起来的。实际上,人们发现尽管他们可以编写像著名的“nervous text”那样栩栩如生的applet,但是在JDK1.0安全模式下无法发挥其一整套非常有用的作用。例如,由于JDK1.0下的applet要受到严密的监督,因此,即使applet在公司安全内部网上运行时的风险相对较小,applet也无法在企业内部网上发挥很大的作用。Sun公司很快就认识到,要使applet真正变得非常有用,用户必须可以根据applet的来源为其分配不同的安全级别。如果applet来自值得信赖的提供商,并且没有被篡改过,那么applet的用户就可以决定是否给applet授予更多的

运行特权。

如果要给予applet更多的信赖,你必须知道下面两件事:

(1)applet来自哪里?

(2)在传输过程中代码是否被破坏?

在过去的50年里,数学家和技术机科学家已经开发出各种各样成熟的

算法,用于确保数据和电子签名的完整性,在java.security包中包含了许多

这些算法的实现。在下面几节,我们将要介绍消息摘要是如何检测数据文件

中的变化的,以及数字签名是如何证明签名者的身份的。

消息摘要是数据块的数字指纹。例如,所谓的SHA1(安全散列算法#1)

可将任何数据块,无论其数据有多长,都压缩为160位(20字节)的序列。

与真实的指纹一样,人们希望任何两条消息都不会有相同的SHA1指纹。当

然这是不可能的—因为只存在2160 个SHA1指纹,所有肯定会有某些消息具

有相同的指纹。因为2160是一个很大的数字,所以存在重复指纹的可能性微

乎其微,那么这种重复的可能性到底小到什么程度呢?根据James Walsh在

他的《True Odds:How Risks Affect Your Everyday Life》,Merritt Publishing出

版社1996年出版,一书中所阐述的,你和他们所有的人都死于雷击的概率,

比伪造的消息与原来消息具有相同的SHA1指纹的概率还要高。(当然,可

能有你不认识的其他10个以上的人会死于雷击,但这里我们讨论的是你选

择的特定的人的死亡概率)。

消息摘要具有两个基本属性:

(1)如果数据的1位或者几位改变了,那么消息摘要也将改变。

(2)拥有给定消息的伪造者不能创建与原消息具有相同摘要的假消息。

当然,第二个属性又是一个概率问题。让我们来看看下面这位亿万富翁

“我死了之后,我的财产将由我的孩子平分,但是,我的儿子George 下的遗嘱:

应该拿不到一个子。”

这份遗嘱的SHA1指纹为:

2D 8B 35 F3 BF 49 CD B1 94 04 E0 66 21 2B 5E 57 70 49 E1 7E

这位有疑心病的父亲将这份遗嘱交给一位律师保存,而将指纹交给另一

位律师保存。现在,假设George能够贿赂那位保存遗嘱的律师,他想修改

这份遗嘱,使得Bill一无所得。当然,这需要将原指纹改为下面这样完全不

同的位模式:

2A 33 0B 4B B3 FE CC 1C 9D 5C01 A7 09 51 0B 49 AC8F 98 92

那么George能够找到与该指纹相匹配的其他文字吗?如果从地球形成之时,他就很自豪地拥有10亿台计算机,每台计算机每秒钟处理一百万条信息,他依然无法找到一个能够替换的遗嘱。

人们已经设计出大量的算法,用于计算这些消息摘要,其中最著名的两种算法是SHAI和MD5。SHAI是由美国国家标准和技术学会开发的加密散列算法,MD5是由麻省理工学院的Ronald Rivest发明的算法。这两种算法都使用了独特巧妙的方法对消息中的各个位进行扰乱。如果要了解这些方法的详细信息,请参阅William Stallings撰写的《Cryptography and Network Security》一书,该书由Prentice Hall出版社于2005年出版口值得注意的是,最近人们在这两种算法中发现了某些微妙的规律性,因此许多密码人员建议最好避免使用MD5,而应该使用SHA1算法,直到有更强的加密算法出现。(查看https://www.360docs.net/doc/8413234615.html,/rsalabs/node.asp?id=2834以了解更多的信息)。

Java编程语言已经实现了SHA1和MD5。MessageDigest类是用于创建封装了指纹算法的对象的“工厂”,它的静态方法getInstance返回继承了MessageDigest类的某个类的对象。这意味着MessageDigest类能够承担下面的双重职责:

(1)作为一个工厂类。

(2)作为所有消息摘要算法的超类。

例如,下面是如何获取一个能够计算SHA指纹的对象的方法:

MessageDig est alg = MessageDigest.getInstance(“SHA-1”);

(如果要获取计算MD5的对象,请使用字符串“MD5”作为getInstance 的参数。)

当你已经获取MessageDigest对象之后,通过反复调用update方法,将信息中的所有字节提供给该对象。例如,下面的代码将文件中的所有字节传给上面建立的alg对象,以执行指纹算法:

InputStream in=….

int ch;

while((ch=in.read())!=-1)

alg.updat((byte) ch);

另外,如果这些字节存放在一个数组中,那就可以一次完成整个数组的更新:

byte[] bytes =...;

alg.update(bytes);

当完成上述操作后,调用digest方法。该方法填充输入信息—指纹算法需要的—并且进行相应的计算,然后以字节数组的形式返回消息摘要。

byte[] hash=alg.digest();

程序清单9-15中的程序计算了一个消息摘要,既可以用SHA,也可以使用MD5来计算。可以从文件加载需要计算摘要的数据,也可以直接将信息输入文本区域。图9-11显示了该应用程序的画面。

消息签名

在上一节中,我们介绍了如何计算原始消息的消息摘要和指纹的方法。如果消息改变了,那么改变后的消息的指纹与原消息的指纹将不匹配。如果消息和它的指纹是分开传送的,那么接收者就可以检查消息是否被篡改过。但是,如果消息和指纹同时被截获了,对消息进行修改,再重新计算指纹,这是一件很容易的事情。毕竟,消息摘要算法是公开的,不需要使用任何密钥。在这种情况下,假消息和新指纹的接收者永远不会知道消息已经被篡改。数字签名解决了这个问题。

为了了解数字签名的工作原理,我们需要解释关于公共密钥加密技术领域中的几个概念。公共密钥加密技术是基于公共密钥和私有密钥这个两个基本概念的。它的设计思想是你可以将公共密钥告诉世界上的任何人,但是,只有自己才拥有私有密钥,重要的是你要保护你的私有密钥,不将它泄漏给其他任何入。这些密钥之间存在一定的数学关系,但是这种关系的具体性质对于实际的编程来说并不重要(如果你有兴趣,可以参阅http://www.cacr.math.uwaterloo.ca/hac/站点上的《The Handbook of Applied Cryptography》一书)。

密钥非常长,而且很复杂。例如,下面是一对匹配的数字签名算法(DSA)公共密钥和私有密钥。

公共密钥:

p:

fca682ce8e12caba26efccf7ll0e526db078b05e6ecbcdleb4a208f3ae1617ae0lf 35b9la47e6df63413c5e12ed0899bcd132acd50d9915lbdc43ee737592el7

q: 962eddcc369cba8ebb260ee6b6a126d9346e38c5

g:67847lb27a9cf44ee9la49c5147dbla9aaf244f05a434d648693ld2d142 7lb9e35030b7lfd73da179069b32e2935630elc2062354d0da20a6c416e50be7 94ca4

y:

c0b6e67b4ac098ebla32c5f8c4clfee7e6fb9d832532e27d0bdab9ca2d2a8 123ce5a8018b816la6048efadd040b927281ddb22cb9bc4df596d7de4dlb977d S0

私有密钥:

p:

fca682ce8e12caba26efccf7ll0e526db078b05edecbcdleb4a208f3ae1617a e0lf35b9la47e6df63413c5e12ed0899bcd132acd50d9915lbdc43ee737592e17 q: 962eddcc369cba8ebb260ee6b6a126d9346e38c5

g:

67847lb27a9cf44ee9la49c5147dbla9aaf244f05a434d648693ld2d1427lb 9e35030b7lfd73da179069b32e2935630elc2062354d0da20a6c416e50be794c a4

x: 146c09f881656cc6c5lf27ea6c3a9lb85edld70a

在现实中,几乎不可能用一个密钥去推算出另一个密钥。也就是说,即使每个人都知道你的公共密钥,不管他们拥有多少计算资源,他们一辈子也无法计算出你的私有密钥。

任何人都无法根据公共密钥来推算私有密钥,这似乎让人难以置信。但是时至今日,还没有人能够找到一种算法,来为现在常用的加密算法进行这种推算。如果密钥足够长,那么要是使用穷举法—也就是直按试验所有可能的密钥—所需要的计算机将比用太阳系中的所有原子来制造的计算机还要多,而且还得花费数千年的时间。当然,可能会有人提出比穷举更灵活的计算密钥的算法。例如,RSA算法(该加密算法由Rivest, Shamir和Adleman

发明)就利用了对数值巨大的数字进行因子分解的困难性。在最近20年里,许多优秀的数学家都在尝试提出好的因子分解算法,但是迄今为止都没有成功。据此,大多数密码学者认为,拥有2000位或者更多位“模数”的密钥目前是完全安全的,可以抵御任何攻击。DSA被认为具有类似的安全性。

图9-12展示了这项工作的处理过程。

假设Alice想要给Bob发送一个消息,Bob想知道该消息是否来自Alice,而不是冒名顶替者。Alice写好了消息,并且用她的私有密钥对该消息摘要签名。Bob得到了她的公共密钥的拷贝,然后Bob用公共密钥对该签名进行校验。如果通过了校验,则Bob可以确认以下两个事实:

(1)原始消息没有被篡改过。

(2)该消息是由Alice签名的,她是私有密钥的持有者,该私有密钥就是Bob

与她用于校验的公共密钥相匹配的密钥。

你可以看到私有密钥的安全性为什么是最重要的。如果某个人偷了Alice的私有密钥,或者政府要求她交出私有密钥,那么她就麻烦了。小偷或者政府代表就可以假扮她的身份来发送消息和资金转账指令等等,而其他人则会相信这些消息确实来自于Alice。

X.509证书格式

为了利用公共密钥这种密码系统,必须将公共密钥分发出去。最通用的一种签名证书格式称为X.509格式。X.509格式的证书被VeriSign、微软、网景和其他许多公司广泛应用于对电子邮件消息进行签名,对程序代码进行认证,以及对许多其他类型的数据进行认证等等。X.509标准是由国际电话标准机构,即国际电报电话咨询委员会(CCITT)提出的用于目录服务的X.500系列建议的组成部分。

X.509证书的具体结构是用一种形式化表示来描述的,称为“抽象语法表示法#1”(abstract syntax notation)即ASN.1。图9-13显示了第3版X.509格式的ASN.1定义。虽然具体的语法对我们并不重要,但是你可以看到,ASN.1为证书文件的结构给出了精确的定义。“基本编码规则”(basic encoding rules),即BER,精确地描述了如何将该结构保存为二迸制文件。也就是说,BER描述了如何对整数、字符串、位串以及诸如SEQUENCE、

CHOICE和OPTIONAL的结构进行编码的方法。

附录5 外文原文

Core Java? Volume II–Advanced Features When Java technology first appeared on the scene, the excitement was not about a well-crafted programming language but about the possibility of safely executing applets that are delivered over the Internet (see V olume I, Chapter 10 for more information about applets). Obviously, delivering executable applets is practical only when the recipients are sure that the code can't wreak havoc on their machines. For this reason, security was and is a major concern of both the designers and the users of Java technology. This means that unlike other languages and systems, where security was implemented as an afterthought or a reaction to break-ins, security mechanisms are an integral part of Java technology.

Three mechanisms help ensure safety:

?Language design features (bounds checking on arrays, no unchecked type conversions, no pointer arithmetic, and so on).

?An access control mechanism that controls what the code can do (such as file access, network access, and so on).

?Code signing, whereby code authors can use standard cryptographic algorithms to authenticate Java code. Then, the users of the code can determine exactly who created the code and whether the code has been altered after it was signed.

Below, you'll see the cryptographic algorithms supplied in the java.security package, which allow for code signing and user authentication.

As we said earlier, applets were what started the craze over the Java platform. In practice, people discovered that although they could write animated applets like the famous "nervous text" applet, applets could not do a whole lot of useful stuff in the JDK 1.0 security model. For example, because applets under JDK 1.0 were so closely supervised, they couldn't do much good on a corporate intranet, even though relatively little risk attaches to executing an applet from your company's secure intranet. It quickly became clear to Sun that for applets to become truly useful, it was important for users to be able to assign different levels of security, depending on where the applet originated. If an applet comes from a trusted supplier and it has not been tampered with, the user of that applet can then decide whether to give the applet

more privileges.

To give more trust to an applet, we need to know two things:

?Where did the applet come from?

?Was the code corrupted in transit?

In the past 50 years, mathematicians and computer scientists have developed sophisticated algorithms for ensuring the integrity of data and for electronic signatures. The java.security package contains implementations of many of these algorithms. Fortunately, you don't need to understand the underlying mathematics to use the algorithms in the java.security package. In the next sections, we show you how message digests can detect changes in data files and how digital signatures can prove the identity of the signer.

A message digest is a digital fingerprint of a block of data. For example, the so-called SHA1 (secure hash algorithm #1) condenses any data block, no matter how long, into a sequence of 160 bits (20 bytes). As with real fingerprints, one hopes that no two messages have the same SHA1 fingerprint. Of course, that cannot be true—there are only 2160 SHA1 fingerprints, so there must be some messages with the same fingerprint. But 2160 is so large that the probability of duplication occurring is negligible. How negligible? According to James Walsh in True Odds: How Risks Affect Your Everyday Life (Merritt Publishing 1996), the chance that you will die from being struck by lightning is about one in 30,000. Now, think of nine other people, for example, your nine least favorite managers or professors. The chance that you and all of them will die from lightning strikes is higher than that of a forged message having the same SHA1 fingerprint as the original. (Of course, more than ten people, none of whom you are likely to know, will die from lightning strikes. However, we are talking about the far slimmer chance that your particular choice of people will be wiped out.)

A message digest has two essential properties:

?If one bit or several bits of the data are changed, then the message digest also changes.

? A forger who is in possession of a given message cannot construct a fake message that has the same message digest as the original.

The second property is again a matter of probabilities, of course. Consider the following message by the billionaire father:"Upon my death, my property shall be divided equally among my children; however, my son George shall receive nothing."

That message has an SHA1 fingerprint of

2D 8B 35 F3 BF 49 CD B1 94 04 E0 66 21 2B 5E 57 70 49 E1 7E

The distrustful father has deposited the message with one attorney and the fingerprint with another. Now, suppose George can bribe the lawyer holding the message. He wants to change the message so that Bill gets nothing. Of course, that changes the fingerprint to a completely different bit pattern:

2A 33 0B 4B B3 FE CC 1C 9D 5C01 A7 09 51 0B 49 AC8F 98 92

Can George find some other wording that matches the fingerprint? If he had been the proud owner of a billion computers from the time the Earth was formed, each computing a million messages a second, he would not yet have found a message he could substitute.

A number of algorithms have been designed to compute these message digests. The two best-known are SHA1, the secure hash algorithm developed by the National Institute of Standards and Technology, and MD5, an algorithm invented by Ronald Rivest of MIT. Both algorithms scramble the bits of a message in ingenious ways. For details about these algorithms, see, for example, Cryptography and Network Security, 4th ed., by William Stallings (Prentice Hall 2005). Note that recently, subtle regularities have been discovered in both algorithms. At this point, most cryptographers recommend avoiding MD5 and using SHA1 until a stronger alternative becomes available. (See https://www.360docs.net/doc/8413234615.html,/rsalabs/node.asp?id=2834 for more information.)

The Java programming language implements both SHA1 and MD5. The MessageDigest class is a factory for creating objects that encapsulate the fingerprinting algorithms. It has a static method, called getInstance, that returns an object of a class that extends the MessageDigest class. This means the MessageDigest class serves double duty:

?As a factory class

?As the superclass for all message digest algorithms

For example, here is how you obtain an object that can compute SHA fingerprints:

MessageDigest alg = MessageDigest.getInstance("SHA-1");

(To get an object that can compute MD5, use the string "MD5" as the argument to getInstance.)

After you have obtained a MessageDigest object, you feed it all the bytes in the

message by repeatedly calling the update method. For example, the following code passes all bytes in a file to the alg object just created to do the fingerprinting:InputStream in = . . .

int ch;

while ((ch = in.read()) != -1)

alg.update((byte) ch);

Alternatively, if you have the bytes in an array, you can update the entire array at once:

byte[] bytes = . . .;

alg.update(bytes);

When you are done, call the digest method. This method pads the input—as required by the fingerprinting algorithm—does the computation, and returns the digest as an array of bytes.

byte[] hash = alg.digest();

The program in Listing 9-15 computes a message digest, using either SHA or MD5. You can load the data to be digested from a file, or you can type a message in the text area.

Message Signing

In the last section, you saw how to compute a message digest, a fingerprint for the original message. If the message is altered, then the fingerprint of the altered message will not match the fingerprint of the original. If the message and its fingerprint are delivered separately, then the recipient can check whether the message has been tampered with. However, if both the message and the fingerprint were intercepted, it is an easy matter to modify the message and then recompute the fingerprint. After all, the message digest algorithms are publicly known, and they don't require secret keys. In that case, the recipient of the forged message and the recomputed fingerprint would never know that the message has been altered. Digital signatures solve this problem.

To help you understand how digital signatures work, we explain a few concepts from the field called public key cryptography. Public key cryptography is based on the notion of a public key and private key. The idea is that you tell everyone in the world your public key. However, only you hold the private key, and it is important that you safeguard it and don't release it to anyone else. The keys are matched by mathematical relationships, but the exact nature of these relationships is not important for us. (If you

are interested, you can look it up in The Handbook of Applied Cryptography at http: // www. Cacr . math. uwaterloo . ca / hac / .)

The keys are quite long and complex. For example, here is a matching pair of public and private Digital Signature Algorithm (DSA) keys.

Public key:

Code View:

p:

fca682ce8e12caba26efccf7110e526db078b05edecbcd1eb4a208f3ae1617ae01f3 5b91a47e6df63413c5e12ed0899bcd132acd50d99151bdc43ee737592e17

q: 962eddcc369cba8ebb260ee6b6a126d9346e38c5

g:678471b27a9cf44ee91a49c5147db1a9aaf244f05a434d6486931d2d14271b9e3 5030b71fd73da179069b32e2935630e1c2062354d0da20a6c416e50be794ca4

y:

c0b6e67b4ac098eb1a32c5f8c4c1f0e7e6fb9d832532e27d0bdab9ca2d2a8123ce5 a8018b8161a760480fadd040b927281ddb22cb9bc4df596d7de4d1b977d50

Private key:

Code View:

p:

fca682ce8e12caba26efccf7110e526db078b05edecbcd1eb4a208f3ae1617ae01f3 5b91a47e6df63413c5e12ed0899bcd132acd50d99151bdc43ee737592e17

q: 962eddcc369cba8ebb260ee6b6a126d9346e38c5

g:

678471b27a9cf44ee91a49c5147db1a9aaf244f05a434d6486931d2d14271b9e35 030b71fd73da179069b32e2935630e1c2062354d0da20a6c416e50be794ca4

x: 146c09f881656cc6c51f27ea6c3a91b85ed1d70a

It is believed to be practically impossible to compute one key from the other. That is, even though everyone knows your public key, they can't compute your private key in your lifetime, no matter how many computing resources they have available.

It might seem difficult to believe that nobody can compute the private key from the public keys, but nobody has ever found an algorithm to do this for the encryption algorithms that are in common use today. If the keys are sufficiently long, brute force—simply trying all possible keys—would require more computers than can be built from all the atoms in the solar system, crunching away for thousands of years. Of course, it is possible that someone could come up with algorithms for computing

keys that are much more clever than brute force. For example, the RSA algorithm (the encryption algorithm invented by Rivest, Shamir, and Adleman) depends on the difficulty of factoring large numbers. For the last 20 years, many of the best mathematicians have tried to come up with good factoring algorithms, but so far with no success. For that reason, most cryptographers believe that keys with a "modulus" of 2,000 bits or more are currently completely safe from any attack. DSA is believed to be similarly secure.

Figure 9-12 illustrates how the process works in practice.

Suppose Alice wants to send Bob a message, and Bob wants to know this message came from Alice and not an impostor. Alice writes the message and then signs the message digest with her private key. Bob gets a copy of her public key. Bob then applies the public key to verify the signature. If the verification passes, then Bob can be assured of two facts:

?The original message has not been altered.

?The message was signed by Alice, the holder of the private key that matches the public key that Bob used for verification.

You can see why security for private keys is all-important. If someone steals Alice's private key or if a government can require her to turn it over, then she is in trouble. The thief or a government agent can impersonate her by sending messages, money transfer instructions, and so on, that others will believe came from Alice.

The X.509 Certificate Format

To take advantage of public key cryptography, the public keys must be distributed. One of the most common distribution formats is called X.509. Certificates in the X.509 format are widely used by VeriSign, Microsoft, Netscape, and many other companies, for signing e-mail messages, authenticating program code, and certifying many other kinds of data. The X.509 standard is part of the X.500 series of recommendations for a directory service by the international telephone standards body, the CCITT.

The precise structure of X.509 certificates is described in a formal notation, called "abstract syntax notation #1" or ASN.1. Figure 9-13 shows the ASN.1 definition of version 3 of the X.509 format. The exact syntax is not important for us, but, as you can see, ASN.1 gives a precise definition of the structure of a certificate file. The basic encoding rules, or BER, and a variation, called distinguished encoding rules (DER) describe precisely how to save this structure in a binary file. That is, BER

and DER describe how to encode integers, character strings, bit strings, and constructs such as SEQUENCE, CHOICE, and OPTIONAL.

外文翻译java

外文资料译文及原文 Java Java I/O 系统 对编程语言的设计者来说,创建一套好的输入输出(I/O)系统,是一项难度极高的任务。 这一点可以从解决方案的数量之多上看出端倪。这个问题难就难在它要面对的可能性太多了。不仅是因为有那么多I/O的源和目地(文件,控制台,网络连接等等),而且还有很多方法(顺序的『sequential』,随机的『random-access』,缓存的『buffered』,二进制的『binary』,字符方式的『character』,行的『by lines』,字的『by words』,等等)。 Java类库的设计者们用"创建很多类"的办法来解决这个问题。坦率地说Java I/O系统的类实在是太多了,以至于初看起来会把人吓着(但是,具有讽刺意味的是,这种设计实际上是限制了类的爆炸性增长)。此外,Java在1.0版之后又对其I/O类库作了重大的修改,原先是面向byte的,现在又补充了面向Unicode字符的类库。为了提高性能,完善功能,JDK 1.4又加了一个nio(意思是"new I/O"。这个名字会用上很多年)。这么以来,如果你想对Java的I/O 类库有个全面了解,并且做到运用自如,你就得先学习大量的类。此外,了解 I/O类库的演化的历史也是相当重要的。可能你的第一反应是"别拿什么历史来烦我了,告诉我怎么用就可以了!"但问题是,如果你对这段历史一无所知,很快就会被一些有用或是没用的类给搞糊涂了。

本章会介绍Java标准类库中的各种I/O类,及其使用方法。 File 类 在介绍直接从流里读写数据的类之前,我们先介绍一下处理文件和目录的类。 File类有一个极具欺骗性的名字;或许你会认为这是一个关于文件的类,但它不是。你可以用它来表示某个文件的名字,也可以用它来表示目录里一组文件的名字。如果它表示的是一组文件,那么你还可以用list( )方法来进行查询,让它会返回String数组。由于元素数量是固定的,因此数组会比容器更好一些。如果你想要获取另一个目录的清单,再建一个File对象就是了。实际上,叫它"FilePath"可能会更好一些。下面我们举例说明怎样使用这个类及其相关的FilenameFilter接口。 目录列表器 假设你想看看这个目录。有两个办法。一是不带参数调用list( )。它返回的是File对象所含内容的完整清单。但是,如果你要的是一个"限制性列表(restricted list)"的话——比方说,你想看看所有扩展名为.java的文件——那么你就得使用"目录过滤器"了。这是一个专门负责挑选显示File对象的内容的类。 下面就是源代码。看看,用了java.utils.Arrays.sort( )和11章的AlphabeticComparator之后,我们没费吹灰之力就对结果作了排序(按字母顺序): //: c12:DirList.java // Displays directory listing using regular expressions. // {Args: "D.*\.java"} import java.io.*; import java.util.*; import java.util.regex.*; import com.bruceeckel.util.*; public class DirList { public static void main(String[] args) { File path = new File("."); String[] list; if(args.length == 0) list = path.list(); else list = path.list(new DirFilter(args[0])); Arrays.sort(list, new AlphabeticComparator());

Java2实用教程(第5版)习题解答(活动za)

习题解答 习题(第章) 一、问答题 . .需个步骤: 1)用文本编辑器编写源文件。 2)使用编译源文件,得到字节码文件。 3)使用解释器运行程序。 .源文件由若干个类所构成。对于应用程序,必须有一个类含有( [])的方法,含有该方法的类称为应用程序的主类。不一定,但至多有一个类。 .:\\\\;.; .和 . .独行风格(大括号独占行)和行尾风格(左大扩号在上一行行尾,右大括号独占行)二、选择题 .。.。 三、阅读程序 .()。()两个字节码,分别是和。()得到“”,得到“: ”,得到“您好,很高兴认识您”习题(第章) 一、问答题 .用来标识类名、变量名、方法名、类型名、数组名、文件名的有效字符序列称为标识符。标识符由字母、下划线、美元符号和数字组成,第一个字符不能是数字。不是标识符。.关键字就是语言中已经被赋予特定意义的一些单词,不可以把关键字作为名字来用。和不是关键字。个关键字:。 .,,,,,,,。 .常量必须用或为后缀。常量用或为后缀,但允许省略后缀。 .一维数组名。二维数组名。 二、选择题 .。.。.。.。.【代码】【代码】【代码】【代码】。.。 三、阅读或调试程序 .属于操作题,解答略。

.属于操作题,解答略。.属于操作题,解答略。.【代码】:。【代码】:[]。.【代码】:。【代码】:四、编写程序 . { ( []) { (()'你'); (()'我'); (()'他'); } } . { ( [ ]) { 'α''ω'; ( <) (" "); } } 习题(第章) 一、问答题 . .不可以 . . 不是必须的 .结束语句的执行 .可以 二、选择题 .。.。.。 三、阅读程序 .你,苹,甜 .好好 . 四、编程序题 .{

论文及外文翻译格式(标准)

附件5 论文及外文翻译写作格式样例 附录1 内封格式示例(设置成小二号字,空3行) 我国居民投资理财现状及发展前景的研究 (黑体,加粗,小二,居中,空2行) The Research on Status and Future of Inhabitants’ Investment and Financial Management in China (Times New Roman体,加粗,小二,居中,实词首字母大写,空5行) 院系经济与管理学院(宋体,四号,首行缩进6字符) 专业公共事业管理(宋体,四号,首行缩进6字符) 班级 6408101 (宋体,四号,首行缩进6字符) 学号 200604081010 (宋体,四号,首行缩进6字符) 姓名李杰(宋体,四号,首行缩进6字符) 指导教师张芸(宋体,四号,首行缩进6字符) 职称副教授(宋体,四号,首行缩进6字符) 负责教师(宋体,四号,首行缩进6字符) (空7行) 沈阳航空航天大学(宋体,四号,居中) 2010年6月(宋体,四号,居中)

附录2 摘要格式示例(设置成三号,空2行) 摘要(黑体,加粗,三号,居中,两个字之间空两格) (空1行) 我国已经步入经济全球化发展的21世纪,随着市场经济的快速增长和对外开放的进一步深化,我国金融市场发生了巨大的变化。一方面,投资理财所涉及到的领域越来越广,不仅仅是政府、企业、社会组织进行投资理财,居民也逐步进入到金融市场中,开始利用各种投资工具对个人、家庭财产进行打理,以达到资产保值、增值,更好的用于消费、养老等的目的;另一方面,我国居民投资理财观念逐渐趋于成熟化、理性化;同时,其投资理财工具以及方式手段亦越来越向多元化、完善化发展。 本论文以我国居民投资理财为研究对象,综合运用现代经济学、金融学和管理学的理论;统计学、概率学的方法和工具,主要对我国居民投资理财的历史演变、发展现状、意识观念、存在的问题和主要投资理财工具进行了分析和探讨,并提出了改善和促进我国居民理财现状的对策和建议,指出了普通居民合理化投资理财的途径。 摘要以浓缩的形式概括研究课题的内容,摘要应包括论文的创新性及其理论和实际意义。摘要中不宜使用公式、图表,不标注引用文献编号。中文摘要在300-500字左右。(首行缩进两个字符,宋体,小四,行距最小值:22磅)(空1行) 关键词:(宋体,小四,加粗,左缩进:0)投资理财资理财工具通货膨胀(宋体,小四,每个关键词之间空两格,关键词的个数在3到5个之间)

JAVA外文文献+翻译

Java and the Internet If Java is, in fact, yet another computer programming language, you may question why it is so important and why it is being promoted as a revolutionary step in computer programming. The answer isn’t immediately obvious if you’re coming from a traditional programming perspective. Although Java is very useful for solving traditional stand-alone programming problems, it is also important because it will solve programming problems on the World Wide Web. 1.Client-side programming The Web’s in itial server-browser design provided for interactive content, but the interactivity was completely provided by the server. The server produced static pages for the client browser, which would simply interpret and display them. Basic HTML contains simple mechanisms for data gathering: text-entry boxes, check boxes, radio boxes, lists and drop-down lists, as well as a button that can only be programmed to reset the data on the form or “submit” the data on the form back to the server. This submission passes through the Common Gateway Interface (CGI) provided on all Web servers. The text within the submission tells CGI what to do with it. The most common action is to run a program located on the server in a directory that’s typically called “cgi-bin.” (If you watch the address window at the top of your browser when you push a button on a Web page, you can sometimes see “cgi-bin” within all the gobbledygook there.) These programs can be written in most languages. Perl is a common choice because it is designed for text manipulation and is interpreted, so it can be installed on any server regardless of processor or operating system. Many powerful Web sites today are built strictly on CGI, and you can in fact do nearly anything with it. However, Web sites built on CGI programs can rapidly become overly complicated to maintain, and there is also the problem of response time. The response of a CGI program depends on how much data must

Java2实用教程试题

课程代码:座位号: 新疆大学期末考试 《Java2实用教程》试卷 姓名:王多强 学号:20102006014专业:机械工程及自动化 第一部分选择题(共12分) 一、单项选择题(本大题共4小题,每题只有一个正确答案,答对一题得3分,共12分) 1、下面的代码段中,执行之后i 和j 的值是什么?【C 】 inti=1; intj; j=i++; A 、1,1 B 、1,2 C 、2,1 D 、2,2 2、已知如下的命令执行javaMyTestabc 【C 】 请问哪个语句是正确的? A 、args[0]="MyTestabc" B 、args[0]="MyTest" C 、args[0]="a"

D、args[2]='b' 3、以下哪个方法用于定义线程的执行体?【B】 A、start() B、init() C、run() D、main() 4、下面哪个函数是publicvoidexample(){...}的重载函数【A】 A、publicvoidexample(intm){...} B、publicintexample1(){...} C、publicvoidexample2(){...} D、以上都不对 第二部分非选择题(共88分) 二、名词解释(本大题3小题,每题4分,共12分。) 1、方法重载 答:方法重载就是在类中可以创建多个方法,它们具有相同的名字,但具有不同的参数和不同的定义。调用方法时通过传递给它们的不同个数和类型的参数来决定具体使用哪个方法。 2、构造方法 答:在Java中,任何变量在被使用前都必须先设置初值.Java提供了为类的成员变量赋初值的专门方法即构造方法,它是一种特殊的成员方法。 3、多态 答:多态就是一个方法名可以通过不同参数(参数名,参数个数)来重复使用,表示不同的意思,即一个名字多种功能用法,分为通用的多态和特定的多态两种。

JAVA外文文献翻译基于Java技术的Web应用设计模型的比较研究

中文翻译 基于Java技术的Web应用设计模型的比较研究 来源:School of Computer Science and Engineering University of New South Wales Sydney, NSW 2052, Australia 作者:Budi Kurniawan and Jingling Xue 摘要 Servlet技术是在建立可扩展性Web应用中被应用最广泛的技术。在运用JAVA技术开发Web应用中有四种模型,分别是:Model 1、Model 2、Struts和JavaServer Faces JSF。Model 1使用一连串的JSP页面,Model 2采用了模型,视图,控制器MVC模式。Struts是一个采用了Model 2设计模型的框架,JSF是一种支持ready-to-use组件来进行快速Web应用开发的新技术。Model 1对于中等和大型的应用来说很难维护,所以不推荐使用。本文通过利用Model 2、Struts和JSF这三种模型分别构建三个不同版本的在线商店应用程序来比较和评价这三种模型在应用程序开发和性能上的差异。 1.绪论 当今Web应用是一种展现动态内容的最普遍的方式。构建Web应用有许多种方法,其中最流行的是Servlet技术。这种技术的流行是因为它比CGI、PHP等其他技术更具优越性。然而Servlet对于开发来说还是麻烦的,因为它在传送HTML 标签时需要程序员将他们组合成为一个字符串对象,再将这个对象传给浏览器。同样的,对于输出的一个很小的改动也要求Servlet被重新编译。基于这个原因SUN 公司发明了JavaServer Pages JSP技术。JSP允许HTML标签和Java代码混合在

Java2实用教程(第5版)习题解答

习题解答 习题1(第1 章) 一、问答题 1. James Gosling 2.需 3 个步骤: 1)用文本编辑器编写源文件。 2)使用 javac 编译源文件 ,得到字节码文件。 3)使用解释器运行程序。 3 .源文件由若干个类所构成。对于应用程序,必须有一个类含有 public static void main(String args[]) 的方法,含有该方法的类称为应用程序的主类。不一定,但至多有一个 public 类。 4. set classpath=D:\jdk\jre\lib\rt.jar;.; 5.java 和 class 6.java Bird 7.独行风格(大括号独占行)和行尾风格(左大扩号在上一行行尾,右大括号独占行) 二、选择题 1.B。 2. D。 三、阅读程序 1. ( a) Person.java。 ( b)两个字节码,分别是 Person.class 和 Xiti.class。 ( c)得到 “ NoSuchMethodError ”,得到“ NoClassDefFoundError: Xiti/class ”,得到“您好,很高兴认识您nice to meet you” 习题2(第2 章) 一、问答题 1.用来标识类名、变量名、方法名、类型名、数组名、文件名的有效字符序列称为标识符。标识符由字母、下划线、美元符号和数字组成,第一个字符不能是数字。 false 不是标识符。 2.关键字就是 Java 语言中已经被赋予特定意义的一些单词,不可以把关键字作为名字来 用。 true 和 false 不是关键字。 6 个关键字: class implements interface enum extends abstract。 3. boolean, char, byte, short, int, long, float, double。 4. float 常量必须用 F 或 f 为后缀。 double 常量用 D 或 d 为后缀,但允许省略后缀。 5.—维数组名.length。二维数组名.length。 二、选择题 1.C。 2. ADF 。 3. B。 4. BE。 5.【代码2】【代码3】【代码4】【代码5】。 6. B。

2016年外文翻译撰写要求与格式规范x

沈阳工业大学本科生 毕业设计(论文)外文翻译撰写要求与格式规范 根据《沈阳工业大学毕业设计(论文)工作的规定》,对本科生毕业设计(论文)外文翻译要求如下: 一、参加毕业设计(论文)的学生必须翻译一篇外文原文资料(外语专业除外)。 二、外文文献应由指导教师审定,必须与所学专业及毕业设计内容密切相关。 三、外文文献应选自学术期刊、学术会议的文章、著作及其他相关材料,并列入毕业设计(论文)的参考文献。 四、外文文献要不少于一万二千个外文印刷符号(约三千汉字)。 五、指导教师应对学生外文翻译与毕业设计内容的相关性、翻译量及翻译的准确性等进行综合评价,手写不少于40字的评语并签名。 六、外文原文可以复印,也可以打印电子期刊原文。 七、译文采用A4纸印刷,边距:上下2.54厘米,左3.50厘米,右2.5厘米,左侧装订。大标题黑体小三号字,一级标题黑体四号,二级标题黑体小四号,正文宋体小四号。 八、装订顺序依次为封面、原文、译文、指导教师评语。 教务处 2016年3月

本科生毕业设计(论文)外文翻译 学院:文法学院 学号:140607214 专业班级:环境设计1402班 学生姓名:辛萌 指导教师:王磊 2018年3 月14 日

Landscape planning and design of residential green space 1 topic sources The project comes from the social production practice of the instructor. 2 purpose and significance of research 2.1 the purpose of the study The modern residential district is increasing with unprecedented speed and quantity, and the landscape design of residential area is becoming more and more important. The landscape is usually in a variety of ways to meet different users. The goal of the design is to create a space that combines society, environment, culture, aesthetics and practical functions. Therefore, the landscape is a system of living, dynamic, ecological and cultural. The landscape design of residential area is closely related to our relationship. It has its own characteristics and development trend. With the rapid development of modern Chinese cities, global integration has made frequent international exchanges and highly shared information. How to assimilate the latest technological achievements and design trend of the world with conditional self concept is one of the common concerns of contemporary designers. The purpose of this study is to analyze the landscape planning and design of modern residential areas at home and abroad, and to summarize the landscape planning and design scheme suitable for the two phase of Ziyun government. For the fusion of classical and modern, Qucuqujing, with European style as the theme, to learn the essence China garden, ideal residential environment, the creation of ecological environment protection and sustainable development, to create a good living environment for residents. 2.2 significance of research The survival of mankind is inseparable from the necessities of life, and the content and content of life are all generated by living. This kind of living activity is called "the first activity of the city" in the Athens charter. As the main place of human activity - the residential area, it bears our needs for a good life. The advantages and disadvantages of human living environment not only relate to people's quality of life and health, but also reflect the culture of the city. As an index of improving the quality of people's life, urban landscape plays a decisive role. Landscape design of residential area has also become an indispensable part of urban landscape system. The design of an

JAVA思想外文翻译毕业设计

文献来源:Bruce Eckel.Thinking in Java [J]. Pearson Higher Isia Education,2006-2-20. Java编程思想 (Java和因特网) 既然Java不过另一种类型的程序设计语言,大家可能会奇怪它为什么值得如此重视,为什么还有这么多的人认为它是计算机程序设计的一个里程碑呢?如果您来自一个传统的程序设计背景,那么答案在刚开始的时候并不是很明显。Java除了可解决传统的程序设计问题以外,还能解决World Wide Web(万维网) 上的编程问题。 1、客户端编程 Web最初采用的“服务器-浏览器”方案可提供交互式内容,但这种交互能力完全由服务器提供,为服务器和因特网带来了不小的负担。服务器一般为客户浏览器产生静态网页,由后者简单地解释并显示出来。基本HTML语言提供了简单的数据收集机制:文字输入框、复选框、单选钮、列表以及下拉列表等,另外还有一个按钮,只能由程序规定重新设置表单中的数据,以便回传给服务器。用户提交的信息通过所有Web服务器均能支持的“通用网关接口”(CGI)回传到服务器。包含在提交数据中的文字指示CGI该如何操作。最常见的行动是运行位于服务器的一个程序。那个程序一般保存在一个名为“cgi-bin”的目录中(按下Web页内的一个按钮时,请注意一下浏览器顶部的地址窗,经常都能发现“cgi-bin”的字样)。大多数语言都可用来编制这些程序,但其中最常见的是Perl。这是由于Perl是专为文字的处理及解释而设计的,所以能在任何服务器上安装和使用,无论采用的处理器或操作系统是什么。 2、脚本编制语言 插件造成了脚本编制语言的爆炸性增长。通过这种脚本语言,可将用于自己客户端程序的源码直接插入HTML页,而对那种语言进行解释的插件会在HTML 页显示的时候自动激活。脚本语言一般都倾向于尽量简化,易于理解。而且由于它们是从属于HTML页的一些简单正文,所以只需向服务器发出对那个页的一

java2实用教程第4版_习题解答

习题解答 习题一(第1章) 一、问答题 1.James Gosling 2.需3个步骤: 1)用文本编辑器编写源文件。 2)使用javac编译源文件,得到字节码文件。 3)使用解释器运行程序。 3.由类所构成,应用程序必须有一个类含有public static void main(String args[])方法,含有该方法的类称为应用程序的主类。不一定,但最多有一个public类。 4.set classpath=D:\jdk\jre\lib\rt.jar;.; 5.java和class 6. java Bird 7.独行风格(大括号独占行)和行尾风格(左大扩号在上一行行尾,右大括号独占行) 二、选择题 1.B。2.D。 三、阅读程序 1.(a)Person.java。(b)两个字节码,分别是Person.class和Xiti.class。(c)得到“NoSuchMethodError”,得到“NoClassDefFoundError: Xiti/class”,得到“您好,很高兴认识您nice to meet you” 习题二(第2章) 一、问答题 1.用来标识类名、变量名、方法名、类型名、数组名、文件名的有效字符序列称为标识符。标识符由字母、下划线、美元符号和数字组成,第一个字符不能是数字。false不是标识符。2.关键字就是Java语言中已经被赋予特定意义的一些单词,不可以把关键字作为名字来用。不是关键字。class implements interface enum extends abstract。 3.boolean,char,byte,short,int,long,float,double。 4.float常量必须用F或f为后缀。double常量用D或d为后缀,但允许省略后缀。5.一维数组名.length。二维数组名.length。 二、选择题 1.C。2.ADF。3.B。4.BE。5.【代码2】【代码3】【代码4】【代码5】。6.B。

外文翻译格式参考报告

毕业设计外文资料翻译 学院:电子工程学院 专业班级:自动化071 学生姓名:陈新鹏学号:030713103 指导教师:马娟丽 外文出处:Multi-focus Image Fusion Algorithms Research Based on Curvelet Transform 附件:1.外文资料翻译译文; 2.外文原文 指导教师评语: 签名: 年月日

基于曲波变换的多聚焦图像融合算法研究 摘要:由于光学透镜聚焦深度的限制,往往很难得到一个包含所有相关聚焦目标的图像。多聚焦图像融合算法可以有效地解决这个问题。基于广泛应用的多聚焦图像融合算法的分析,本文提出一种基于多聚焦图像融合算法的曲波变换。根据曲波变换分解的不同频率区,分别讨论低频系数和高频系数的选择规律。本文中低频系数和高频系数被分别与NGMS(就近梯度最大选择性)和LREMS(局部区域能量最大的选择性)融合。结果表明,提出的多聚焦图像融合算法可以获得和图像聚焦融合算法相同的图像,在客观评价和主观评估方面较其他算法有明显的优势。 关键字:曲波变换;多聚焦图像;融合算法 1.简介 如今,图像融合被广泛应用于军事、遥感、医学和计算机图像等领域。图像融合的主要目的将来自两个或更多相同场景的信息相结合以获得一个包含完整信息的图像。比如,廉价相机的主要问题是我们不能获得不同距离的每个目标以获得一个聚焦所有目标的图像。因此,我们需要一种多聚焦图像融合方法来聚焦和获得更清晰的图像。 经典融合算法包括计算源图像平均像素的灰度值,拉普拉斯金字塔,对比度金字塔,比率金字塔和离散小波变换(DWT)。然而,计算源图像平均像素灰度值的方法导致一些不期望的影响例如对照物减少。小波变换的基本原理是对每个源图像进行分解,然后将所有这些分解单元组合获取合成表示,从中可以通过寻找反变换恢复融合图像。这种方法显然是有效的。但是,小波变化只能通过变换边缘特征反映出来,却不能表达边缘的特点。同时,也因为它采用各向同性所以小波变化无法显示边缘方向。由于小波变换的限制,Donoho 等人提出了曲波变换的概念,它采用边缘作为基本元素,较为成熟并可以适应图像特征。此外,曲波变换具有各向异性和有更好的方向,可以提供更多图像处理的信息。 通过曲波变换的原则我们知道:曲波变化除了具有多尺度小波变换和地方特色外,它还具有方向特征和支持会话的基础特征。曲波变化可以适当代表图像边缘和相同逆变换精度的光滑区。继曲波变化低波段和高波段融合算法系数的研究后,提出一种思想:低-带系数采用NGMS方法和不同的方向高带系数采用LREMS方法。 2.第二代曲波变化 第二代曲波变换和第一代的曲波变换不同的是,没有导入脊波变换的实施过

Java的面向对象编程外文资料翻译

毕业设计(论文)外文资料翻译 系:计算机系 专业:计算机科学与技术 姓名: 学号: 外文出处:Ghosh,D..Java Object-oriented (用外文写) programming[J]. IEEE Transactions on Software Engineering,2009, 13(3):42-45. 附件: 1.外文资料翻译译文;2.外文原文。

注:请将该封面与附件装订成册。

附件1:外文资料翻译译文 Java的面向对象编程 ——面向对象编程和它的关键技术—继承和多态性 软件的重用可以节省程序开发时间。它鼓励重复使用已经调试好的高质量的软件,从而减少系统运行后可能出现的问题。这些都是令人振奋的可能性。多态性允许我们用统一的风格编写程序,来处理多种已存在的类和特定的相关类。利用多态性我们可以方便地向系统中添加新的功能。继承和多态对于解决软件的复杂性是一种有效可行的技术。当创建一个新的类时,而不用完整的写出新的实例变量和实例方法,程序员会指定新的类继承已定义的超类的实例变量和实例方法。这个新的类被称为一个子类。每个子类本身将来亦可有新的子类,而其本身将成为父类。一个类的直接父类就是该类所直接继承的类(通过关键字extends继承)。一个间接超类是通过从两级或更多级以上的类继承而来的。例如,从类JApplet(包javax.swing 中)扩展来的类Applet(包java.applet)。一个类单一的从一个父类继承而来。 Java 不支持多重继承(而C++可以),但它支持接口的概念。接口可以使Java实现许多通过多重继承才能实现的优点而没有关联的问题。我们将在本章讨论的接口的详细内容。我们会给出创建和使用接口的一般规律和具体实例。一个子类通常添加自己的实例变量和自己的实例方法,因此子类通常比父类大。一个子类比它的父类更具体并且代表一组更小、更专业的对象。通过单一继承,子类在开始时拥有父类的所有特性。继承性真正的力量在于它可以在定义子类时增加或取代从超类中继承来的特征。每个子类对象也是该类的父类的对象。例如,每一个我们所定义的小程序被认为是类JApplet 的对象。此外,因为Japplet继承了Applet,每一个我们所定义的小程序同时也被认为是一个Applet 的对象。当开发applets时,这些信息是至关重要的,因为一个小程序容器只有当它是一个Applet才可以执行一个程序。虽然子类对象始终可以作为它的父类的一种来看待,父类对象却不被认为是其子类类型的对象。我们将利用这种“子类对象是父类对象”的关系来执行一些强大的操作。例如,绘图程序可以显示一系列图形,如果所有的图形类型都直接或间接地继

java2实用教程试题

第1章Java 语言入门 1-1开发与运行Java程序需要经过哪些主要步骤和过程? 1-2怎样区分应用程序和小应用程序?应用程序的主类或小应用程序的主类必须用public修饰吗? 1-3Java程序是有什么组成的?一个程序中必须要有public类吗?Java源文件的命名规则是怎样的? 1-4在运行小应用程序的html文件中可以使用codebase属性制定小应用程序的字节码所驻留的目录。如果不使用codebase属性,小应用程序的字节码文件必须和运行它的html在同一目录中,编写一个小应用程序并将它的字节码存放在某个目录中,比如c:\Boy. 把运行该小应用程序的html文件(注意其中的codebase属性): < applet code=你的小程序的字节码wdith=20 height=30 codebase=c:\boy> 存放在另一个目录中(查阅有关编写网页方面的书籍,会有更 详细的关于怎样在一个网页中嵌入一个小应用程序的讲解)。 第2章标识符、关键字和数据类型 2-1上机运行下列程序,注意观察输出的结果。

public class E { public static void main ( string args [ ] ) { for (int i=20302; i<=20302; i++) { System.out. println (( char ) i ); } } 2-2System.out. println (“你好”);可输出字符串值,也可以使用System.out. println()输出变量或表达式的值,只需使用并置 符号:“+”将变量、表达式或一个常数值与一个字符串并置即 可,如System.out. println(“”+x);System.out. println(“:” +123+“大于”+122)等。上机调试下列程序,注意观察结果,特别注意System.out. print()和System.out. println()的区 别。 public class OutputData { public static void main ( string args [ ] ) { int x=234, y=432 ; System.out. println (“:” +x+“<”+2*x); System.out. print (“我输出结果后不回车“); System.out. println (“我输出结果后自动回车到下一行”); } }

java外文翻译

毕业设计外文资料翻译 (译文) 题目名称:Java and the Internet 学院:计算机科学技术 专业年级:计算机科学与技术(师)08 级 学生姓名:aaa 班级学号:a班a号 指导教师:aaa

二○一一年五月十三日 译文题目:Java和因特网 原文题目:Java and the Internet 原文出处:https://www.360docs.net/doc/8413234615.html,/view.html

Java and the Internet If Java is, in fact, yet another computer programming language, you may question why it is so important and why it is being promoted as a revolutionary step in computer programming. The answer isn’t immediately obvious if you’re coming from a traditional programming perspective. Although Java is very useful for solving traditional stand-alone programming problems, it is also important because it will solve programming problems on the World Wide Web. 1.Client-side programming The Web’s initial server-browser design provided for interactive content, but the interactivity was completely provided by the server. The server produced static pages for the client browser, which would simply interpret and display them. Basic HTML contains simple mechanisms for data gathering: text-entry boxes, check boxes, radio boxes, lists and drop-down lists, as well as a button that can only be programmed to reset the data on the form or “submit” the data on the form back to the server. This submission passes through the Common Gateway Interface (CGI) provided on all Web servers. The text within the submission tells CGI what to do with it. The most common action is to run a program located on the server in a directory that’s typically called “cgi-bin.” (If you watch the address window at the top of your browser when you push a button on a Web page, you can so metimes see “cgi-bin” within all the gobbledygook there.) These programs can be written in most languages. Perl is a common choice because it is designed for text manipulation and is interpreted, so it can be installed on any server regardless of processor or operating system. Many powerful Web sites today are built strictly on CGI, and you can in fact do nearly anything with it. However, Web sites built on CGI programs can rapidly become overly complicated to maintain, and there is also the problem of response time. The response of a CGI program depends on how much data must be sent, as well as the load on both the server and the Internet. (On top of this, starting a CGI program tends to be slow.) The initial designers of the Web did not foresee how rapidly this bandwidth would be exhausted for the kinds of applications people developed. For example, any sort of dynamic graphing is nearly impossible to perform with consistency because a GIF file must be created and moved from the server to the client for eac h version of the graph. And you’ve no doubt had direct experience with something as simple as validating the data on an input form. You press the submit button on a page; the data is shipped back to the server; the server starts a CGI program that discovers an error, formats an HTML page informing you of the error, and then sends the page back to you; you must then back up a page and try again. Not only is this slow, it’s inelegant. The solution is client-side programming. Most machines that run Web browsers are powerful engines capable of doing vast work, and with the original static HTML

相关文档
最新文档