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
相关文档:
1.
顺序控制
if
else
switch
可以用byte,short,char,int做为表达式类型
循环结构
while
do ...while
for
标签跳转:
outer:
break outer;
outer:
continue outer;
2.数组类型
数组也是一种数据类型,它本身是引用类型。
静态初始化:程序员显示指定初始值,系统决定长度。
动态 ......
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. ......
package script;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
public class Change {
public static void main(String[] args) throws Exception {
Change c = new Change();
c.utf8toLocaleCode();
&n ......
1. byte 如果没有赋值,那么java会自动将它赋值为 (byte)0;
static String ReadLn (int maxLg) // utility function to read from stdin
{
byte lin[] = new byte [maxLg];
int lg = 0, car = -1;
String line = "";
try
{
while (lg < maxLg)
......