Java读取文件的简单代码
网址: http://blog.csdn.net/justinavril/archive/2008/08/06/2775767.aspx
import
java.io.*;
public
class
FileToString {
public
static
String readFile(String fileName) {
String output = ""
;
File file = new
File(fileName);
if
(file.exists()){
if
(file.isFile()){
try
{
BufferedReader input = new
BufferedReader (
new
FileReader(file));
StringBuffer buffer = new
StringBuffer();
String text;
while
((text = input.readLine()) !=
null
)
&n
相关文档:
package script;
import java.io.File;
import java.io.IOException;
public class Realname {
public static void main(String[] args) throws IOException
{
File oldFile = new File("d:/PMS");
if(!oldFile.exists())
{
oldFile. ......
Java把内存划分成两种:一种是栈内存,一种是堆内存。
在函数中定义的一些基本类型的变量和对象的引用变量都在函数的栈内存中分配。
当在一段代码块定义一个变量时,Java就在栈中为这个变量分配内存空间,当超过变量的作用域后,Java会自动释放掉为该变量 ......
Java
中的常量
常量就是程序里持续不变的值,它是不能改变的数据。
Java
中的常量包含整型常量、浮点数常量、布尔常量等,下面来看一下它们是如何表示的:
整型常量
整型常量可以分为十进制
、十六进制
和八进制
。
十进制
:
0 1 2 3 4 5 6 7 8 9
注意
:以十进制表示时,第一位不能是
0
(数字 ......