资源简介
基于JAVA 的P2P 软件,需JDK 1.3

代码片段和文件信息
import java.net.*;
import java.io.*;
import java.util.*;
/* This class file is a mutipurpose class file it contains many functions which are used
over a series of classes in the project...
*/
class add_on
{
Socket file_socket;
String viewfiles[][];
static Vector filenames ; // A vector to maintain the user list (static)
add_on() // Constructor...
{
}
/* This function is used to adjust the length of the byte array and to make it
equal to 1024 byte this is done in order to make the size of the request
equal to the request accepted by the C# listener...
In the function appropriatelength two parameters are passed
1. Byte array...
2. Length of byte array...
The rest of the bytes (1024 - length) are first converted into character and
then made into char ‘13‘ and then converted into bytes again..
*/
public byte [] appropriatelength(byte[] file_bytes int file_size)
{
int count = 0;
byte b[] = new byte[1024];
int remaining = 1024-file_size;
for (int i = 0;i {
b[i] = file_bytes[i];
}
char a[] = new char[remaining];
for (int i = 0;i {
a[i] = 13;
}
String tempw = new String(a);
byte d[] = tempw.getBytes();
for (int i=file_size;i<1024 ;i++ )
{
b[i] = d[(i-file_size)];
}
return (b);
} // End Appropriate length.....
/* This function is used to issue the search request...
It takes 4 parameters...
1. Directory information...
2. Search Criteria..
3. Ip_address of the listener...
4. Flag_information of the directory on which search is made...
*/
public void search_request(String directory String condition String ip_address String flag_info)
{
try
{
InetAddress inet = InetAddress.getByName(ip_address);
file_socket = new Socket(inet7070); // Create a client_socket on the
// Listener‘s machine at port 7070.
// Get The output as well as the input Streams on that socket...
BufferedOutputStream out = new BufferedOutputStream(file_socket.getOutputStream());
BufferedInputStream br_socket = new BufferedInputStream(file_socket.getInputStream());
// Now a request is sent to the Listener to show all the shareable files
// of the particular directory that satisfy the search criteria..selected
// by the user..
// To send a request a class of the name xmlwriter is used which has two
// functions of interest they are... requestFString(String String) and
// returnRequest() this xmlwriter is a versatile class as it is used to
// generate xml requests for various purposes... SEARCHUPLOAD DOWNLOAD
// and SHOWFILES... therefore accordingly the requestFString takes two
// parameters in case of SHOWFILES the second parameters is not used.
xml
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2005-03-18 12:24 Java Version
目录 0 2005-03-18 12:24 Java Version\Listener
目录 0 2005-03-18 12:24 Java Version\Listener\Source Code
文件 3206 2005-03-18 12:24 Java Version\Listener\Source Code\xm
文件 10839 2005-03-18 12:24 Java Version\Listener\Source Code\Shareddilog.java
文件 16523 2005-03-18 12:24 Java Version\Listener\Source Code\MultiServer.java
文件 14330 2005-03-18 12:24 Java Version\Listener\Source Code\Login.java
文件 8878 2005-03-18 12:25 Java Version\Listener\Source Code\check_directory.java
目录 0 2005-03-18 12:25 Java Version\Listener\Executables
目录 0 2005-03-18 12:25 Java Version\Listener\Executables\ORG
目录 0 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
目录 0 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
目录 0 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 1904 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 3650 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 1179 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 5732 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 1020 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 9926 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 1903 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 2783 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 2942 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 371 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 1148 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 1925 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 4049 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 1975 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
目录 0 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 170 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
文件 499 2005-03-18 12:25 Java Version\Listener\Executables\ORG\xm
............此处省略1200个文件信息
相关资源
- 微博系统(Java源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
评论
共有 条评论