package test.demo001;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* 文件读取写入
* @author OF
* 2015年7月7日
*/
public class FileTest {
public static void main(String[] args) {
Buff();
}
/**
* 读取文件<br/>
* 文件UTF-8编码<br/>
* 对文件每一行进行读取
* line 读文件总行数
*/
public static void Buff(){
File f = new File("d:"+File.separatorChar+"of.txt");
InputStream input = null;
BufferedReader buf= null;
try {
input = new FileInputStream(f);
buf = new BufferedReader(new InputStreamReader(input,"utf-8"));
StringBuffer sb = new StringBuffer();
String text;
String[] tmp = null ;
int line = 0;
String work = "";
while ((text =buf.readLine()) != null){
line ++;
tmp = text.split(",", 10);
work = tmp[1];
String password = MD5.MD5Encode(work+"123456");
System.out.println(password);
}
System.out.println(line);
} catch (Exception e) {
}finally{
try {
buf.close();
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 文件写入<br/>
*
*/
public static void file(){
File f = new File("d:"+File.separatorChar+"of.txt");
FileOutputStream out = null;
InputStream input = null;
try {
f.createNewFile();
out = new FileOutputStream(f,true);
String s ="helloword!";
out.write(s.getBytes());
input = new FileInputStream (f);
byte[] temp = new byte[1024];
StringBuffer ss = new StringBuffer();
int len;
while(( len= input.read(temp)) != -1){
ss.append(new String(temp,0,len));
}
System.out.println(ss.toString());
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
out.close();
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* 文件读取写入
* @author OF
* 2015年7月7日
*/
public class FileTest {
public static void main(String[] args) {
Buff();
}
/**
* 读取文件<br/>
* 文件UTF-8编码<br/>
* 对文件每一行进行读取
* line 读文件总行数
*/
public static void Buff(){
File f = new File("d:"+File.separatorChar+"of.txt");
InputStream input = null;
BufferedReader buf= null;
try {
input = new FileInputStream(f);
buf = new BufferedReader(new InputStreamReader(input,"utf-8"));
StringBuffer sb = new StringBuffer();
String text;
String[] tmp = null ;
int line = 0;
String work = "";
while ((text =buf.readLine()) != null){
line ++;
tmp = text.split(",", 10);
work = tmp[1];
String password = MD5.MD5Encode(work+"123456");
System.out.println(password);
}
System.out.println(line);
} catch (Exception e) {
}finally{
try {
buf.close();
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 文件写入<br/>
*
*/
public static void file(){
File f = new File("d:"+File.separatorChar+"of.txt");
FileOutputStream out = null;
InputStream input = null;
try {
f.createNewFile();
out = new FileOutputStream(f,true);
String s ="helloword!";
out.write(s.getBytes());
input = new FileInputStream (f);
byte[] temp = new byte[1024];
StringBuffer ss = new StringBuffer();
int len;
while(( len= input.read(temp)) != -1){
ss.append(new String(temp,0,len));
}
System.out.println(ss.toString());
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
out.close();
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}