filetransport.java

来自「用java写的浏览器的服务器和客户端程序」· Java 代码 · 共 54 行

JAVA
54
字号
/**
 * Email: taorundong@126.com
 *
 * @author taorundong
 * @version 1.00 07/02/11
 */
 
 import java.util.*;
 import java.net.*;
 import java.io.*;
 
public class FileTransport extends Thread implements Runnable{
	
	File file = null;
	FileInputStream fileInput = null;
	
	
	FileTransport(){
		super();
		
		try{
			file = new File("hello.wav");
			fileInput = new FileInputStream(file);
			
		}
		catch(Exception e){
			e.printStackTrace();
		}
		
		transMission("press.wav");
	}
	
	
	public void transMission(String name){
		
		File temp = new File(name);
		
		try{
			FileOutputStream output = new FileOutputStream(temp);
			byte []b = new byte[100];
			
			while(fileInput.read(b)!=-1){
			output.write(b);
			}
			fileInput.close();
			output.close();
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
	
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?