⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 remoteimpl.java

📁 手机控制邮件以及附件的发送
💻 JAVA
字号:
package remote;import java.rmi.*;import java.io.*;import java.util.Vector;public class RemoteImpl implements RemoteIF {	private Vector fileslist = null;	private Vector dirlist = null;	private SendFileUsingMail fileSend = null;	private CheckUserInfo checkValid = null;	private Thumbnail preview = null;	private Vector storing_list = null;	private Vector storing_details_list = null;	public RemoteImpl(){		storing_list = new Vector();		storing_details_list = new Vector();	}	public boolean checkUserValid(String n,String p,String code) throws RemoteException{		boolean valid = false;		if (code.equals("remote1")){			checkValid = new CheckUserInfo(n);			valid =	checkValid.checkUser(n,p);		}		return valid;	}	public String[] getDriveList(String code) throws RemoteException {		if (code.equals("remote2")){			String namefile = "";			String encodedName = "";			File[] roots = File.listRoots();			int length = roots.length;			String[] list = new String[length];			try{			for (int i=0; i<length; i++){				namefile = roots[i].toString();				encodedName = java.net.URLEncoder.encode(namefile,"UTF-8");				list[i] = encodedName;			}			} catch (Exception e){				e.printStackTrace();			}					return list;		} else			return null;	}	public String[] getFileList(String user,String path,String code) throws RemoteException {		if (code.equals("remote2")){			try{			String p = java.net.URLDecoder.decode(path,"UTF-8");			int storing_list_size = storing_list.size();			for (int i=0; i< storing_list_size; i++){				ListStorage item = (ListStorage)storing_list.elementAt(i);				if (user.equals(item.list_user) && p.equals(item.path)){										fileslist = item.file_list;					item.remove();					storing_list.removeElementAt(i);					break;				}			}			} catch (Exception e){				e.printStackTrace();			}			int count = fileslist.size();			String[] list = new String[count];			for (int i=0; i < count; i++)				list[i] = (String)fileslist.elementAt(i);			return list;		} else			return null;	}	public String[] getDirList(String user,String path,String code) throws RemoteException {				if (code.equals("remote2")){			try{			String p = java.net.URLDecoder.decode(path,"UTF-8");			int storing_list_size = storing_list.size();			for (int i=0; i< storing_list_size; i++){				ListStorage item = (ListStorage)storing_list.elementAt(i);				if (user.equals(item.list_user) && p.equals(item.path)){					dirlist = item.dir_list;					break;				}			}			} catch (Exception e){				e.printStackTrace();			}			int count = dirlist.size();			String[] list = new String[count];			for (int i=0; i < count; i++)	        		list[i] = (String)dirlist.elementAt(i);			return list;		} else			return null;	}	public boolean getFileDetails(String path,String code) throws RemoteException{		if (code.equals("remote3")){			try{			String decoded_path = java.net.URLDecoder.decode(path,"UTF-8");			FileDetails file_details = new FileDetails(decoded_path);			addtoList(storing_details_list,file_details);			} catch (Exception e){				e.printStackTrace();			}			return true;		}		return false;	}	private void addtoList(Vector list,FileDetails d){		list.addElement(d);	}	public boolean getPreview(String path,String user,String code) throws RemoteException{		boolean ready = false;		String decoded_path = "";		if (code.equals("remote4")){			try{			decoded_path = java.net.URLDecoder.decode(path,"UTF-8");			preview = new Thumbnail(decoded_path,user);			ready = preview.createPreview();			} catch (Exception e){				e.printStackTrace();			}		}		return ready;	}	public boolean getPreview2(String path,String user,int w,int h,int q,String code) throws RemoteException{		boolean ready = false;		if (code.equals("remote4")){			try{			String decoded_path = java.net.URLDecoder.decode(path,"UTF-8");			preview = new Thumbnail(decoded_path,user,w,h,q);			ready = preview.createPreview();			} catch (Exception e){				e.printStackTrace();			}		}		return ready;	}	public String getModified(String path,String code) throws RemoteException{		if (code.equals("remote3")){			String date = "";			try{			String decoded_path = java.net.URLDecoder.decode(path,"UTF-8");			int storing_details_list_size = storing_details_list.size();			for (int i=0; i< storing_details_list_size; i++){				FileDetails item = (FileDetails)storing_details_list.elementAt(i);				if (decoded_path.equals(item.path)){					date = item.getLastModified();					break;				}			}			} catch (Exception e){				e.printStackTrace();			}			return date;		} else			return null;	}	public boolean getHidden(String path) throws RemoteException{		boolean result = false;		try{		String decoded_path = java.net.URLDecoder.decode(path,"UTF-8");			int storing_details_list_size = storing_details_list.size();			for (int i=0; i< storing_details_list_size; i++){				FileDetails item = (FileDetails)storing_details_list.elementAt(i);				if (decoded_path.equals(item.path)){					result = item.getIsHidden();					storing_details_list.removeElementAt(i);					break;				}			}		} catch (Exception e){			e.printStackTrace();		}					return result;	}	public long getFileSize(String path,String code) throws RemoteException{		long size = 0;		if (code.equals("remote3")){			try{			String decoded_path = java.net.URLDecoder.decode(path,"UTF-8");			int storing_details_list_size = storing_details_list.size();			for (int i=0; i< storing_details_list_size; i++){				FileDetails item = (FileDetails)storing_details_list.elementAt(i);				if (decoded_path.equals(item.path)){					size = item.getSize();					break;				}			}			} catch (Exception e){				e.printStackTrace();			}		}		return size;	}		public boolean listingFile(String user,String location,String code) throws RemoteException	{		boolean status;		status = false;		// String location = "C:\\";		if (code.equals("remote2")){			try{			String decoded_path = java.net.URLDecoder.decode(location,"UTF-8");			File dir = new File(decoded_path);			fileslist = new Vector();			dirlist = new Vector();			status = listFiles(user,dir,fileslist,dirlist,decoded_path,storing_list);			} catch (Exception e){				e.printStackTrace();			}		}		return status;	}	private static boolean listFiles(String user,File dir,Vector fileslist,Vector dirlist, String path,Vector store_list){		String[] temp = dir.list();		File[] files = dir.listFiles();		String namefile = "";		String encodedName = "";		if (temp == null) {        		// Either dir does not exist or is not a directory			return false;		} else {			try{		        for (int i=0; i<temp.length; i++) {				namefile = temp[i];				encodedName = java.net.URLEncoder.encode(namefile,"UTF-8");				if (files[i].isDirectory())					dirlist.addElement(encodedName);				else					fileslist.addElement(encodedName);			}			} catch (Exception e){				e.printStackTrace();			}						ListStorage list_store = new ListStorage(user,path,dirlist,fileslist);			store_list.addElement(list_store);			return true;		}	}	public boolean sendEmail(String user,String receiver,String t,String c,			String[] file_selected,String code){		boolean sent = false;		String[] file_ready;		String namefile = "";		String decoded_name = "";		String title = "";		String content = "";		if (code.equals("remote5")){			try{			title = java.net.URLDecoder.decode(t,"UTF-8");			content = java.net.URLDecoder.decode(c,"UTF-8");			file_ready = new String[file_selected.length];			for (int i=0; i < file_selected.length; i++){				namefile = file_selected[i];				decoded_name = java.net.URLDecoder.decode(namefile,"UTF-8");				file_ready[i] = decoded_name;			}			fileSend = new SendFileUsingMail(user);			sent =	fileSend.sendMail(receiver,title,content,file_ready);			} catch (Exception e){				e.printStackTrace();			}		}		return sent;	}}

⌨️ 快捷键说明

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