java 文件读写_FileReader
package test;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Test {
public static void main(String arg[]) {
String fileName = "E:\\share\\test.txt";
String writeData = "HelloWorld!\r\nnihao我的内存是3G的 ";
File file = new File(fileName);
if(file.exists()){
file.delete();
}
char[] byteOutData = writeData.toCharArray();
char[] byteInData = new char[50];
int length = 0;
try {
file.createNewFile();
if(file.exists() && file.canWrite()){
FileWriter fileWrite = new FileWriter(file);
fileWrite.write(byteOutData);
fileWrite.close();
}
if (file.exists() && file.canRead()) {
FileReader fileReader = new FileReader(file);
while((length = fileReader.read(byteInData)) !=-1){
System.out.print(new String(byteInData,0,length));
}
fileReader.close();
}
} catch (IOException e) {
System.out.println("IOException occur");
e.getMessage();
}
}
}
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
一:准备 www.savarese.org download
1. rocksaw-1.0.0-src.tar.gz
2. vserv-tcpip-0.9.2-src.tar.gz
二:编译源文件得到jar包 使用Ant
1. build vserv-tcpip-0.9.2-src
在vserv-tcpip-0.9.2目录下面建一个tests目录,然后在cmd窗口下进入 ......
//Number 11 过滤字符串中的非数字字符
import java.util.regex.*;
import java.util.Scanner;
public class GuoLv{
public static void main(String args[]){
Scanner reader = new Scanner(System.in);
  ......
用了这个,MyEclipse里就不会报那些警告了,看起来漂亮多了
常用的:
@SuppressWarnings("unchecked"),泛型
@SuppressWarnings("deprecation"), deprecated方法
@SuppressWarnings(value={"deprecation","unchecked"}) 双选
@SuppressWarnings("serial"), 序列化
......
public class Factory {
private static Factory factory;
private static Object classLock=Factory.class;
private Factory(){}
public static Factory getFactory(){
synchronized(classLock){
......