java io / nio / bio / aio

sdfsafd 未整理

TxtWrite .java

package com.javaeye.lindows.io;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
 
public class TxtWrite {
	
	/**
	 * 利用缓冲流写入文本
	 */
	public void bfWrite() {
		FileOutputStream fos = null;
		try {
			fos = new FileOutputStream("D:\\workspace\\java\\src\\com\\javaeye\\lindows\\io\\文本写入.txt");
			BufferedWriter bWriter = new BufferedWriter(new OutputStreamWriter(fos));
			bWriter.write("你好!\n 我是xxx Lindows.iteye.com ");
			bWriter.flush(); //刷新缓冲流
		} catch (Exception e) {
				e.printStackTrace();
		} finally{ 
				if (fos != null) { 
					try {
						fos.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
		}
	}
	public static void main(String[] args) {
		TxtWrite tWrite = new TxtWrite();
		tWrite.bfWrite(); 
	}
}

 

asdfdasfsf

 TxtRead .java

package com.javaeye.lindows.io;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;

public class TxtRead {
	/*
	 * 利用缓冲流读取文件,比较高效
	 */
	public static StringBuffer sBuffer = new StringBuffer();
	
	public void bfRead() { 
		FileInputStream fis = null; 
		try { 
			/* 写法一 直接路径
			 * fis = new FileInputStream("D:\\workspace\\java\\src\\com\\javaeye\\lindows\\io\\文本读取.txt");
			 * fis = new FileInputStream("D:/workspace/java/src/com/javaeye/lindows/io/文本读取.txt");
			 *  
			 * 写法二 常量接口
			 */
			fis = new FileInputStream(Constant.READ_PATH);
			BufferedReader bReader = new BufferedReader(new InputStreamReader(fis));
			String s;
			while ((s = bReader.readLine()) != null) {
				System.out.println(s); //格式化打印
				sBuffer.append(s);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (fis != null) {
					fis.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	public static void main(String[] args) {
		TxtRead tRead = new TxtRead();
		tRead.bfRead();
		System.out.println("---------------------------");
		System.out.println(sBuffer);  //非格式化打印
	}

}

 

 

sadfsdf 

Constants.java

package com.javaeye.lindows.io;

public interface Constant {
	public static final String READ_PATH = "D:\\workspace\\java\\src\\com\\javaeye\\lindows\\io\\文本读取.txt";
	public static final String WRITE_PATH = "D:\\workspace\\java\\src\\com\\javaeye\\lindows\\io\\文本写入.txt";
}

 

sadffssa

 

java如何远程访问一个共享目录

http://www.iteye.com/topic/276022

 

  1. import  java.io.BufferedInputStream;  
  2. import  java.io.BufferedOutputStream;  
  3. import  java.io.File;  
  4. import  java.io.FileOutputStream;  
  5. import  java.io.IOException;  
  6. import  java.io.InputStream;  
  7. import  java.io.OutputStream;  
  8. import  java.util.Date;  
  9.   
  10. import  jcifs.smb.SmbFile;  
  11. import  jcifs.smb.SmbFileInputStream;  
  12.  

 

 asdfsdfdsf

 

 

end

posted @ 2009-01-09 13:12  siemens800  阅读(18)  评论(0编辑  收藏  举报