f040a6b85b6c001d1b28dd35d501e274

来自「里面所含源码是本人平时做程序的一些实例」· 代码 · 共 69 行

TXT
69
字号
package src.software0611.mxb;

import java.io.*;
import java.net.Socket;

import javax.swing.JOptionPane;

public class Process extends Thread {
	Socket socket;
	InputStream in;
	public final static String WEB_ROOT="E:\\java\\WebProject\\WEB_ROOT";
	public Process(Socket s) {
		this.socket = s;
		try {
			in = socket.getInputStream();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public void run() {

	}

	public String parse() {
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		String fileName=null;
		
		try {
			String message = br.readLine();
			String content[]=message.split("");
			if(content.length!=3){
				JOptionPane.showMessageDialog(null,"文件读取错误!");
				return null;
			}
			System.out.println("code:"+content[0]+",fileName:"+content[1]+"http version:"+content[2]);
			fileName=content[1];
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return fileName;
	}
	
	public void sendFile(){
		File file=new File(Process.WEB_ROOT);
		if(!file.exists()){
			JOptionPane.showMessageDialog(null, "文件没有找到");
			return;
		}
		try {
			InputStream in=new FileInputStream(file);
			byte contFile[]=new byte[(int)file.length()];
			in.read(contFile);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
		
			e.printStackTrace();
		}
		
	}
	public static void main(String[] args) {

	}

}

⌨️ 快捷键说明

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