资源简介
基于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个文件信息
相关资源
- 解决IDEA不支持带BOM的UTF-8编码文件,
- 库存管理系统 数据库课程设计
- 基于JAVA的网上订票系统源码
- jsp+servlet+javabean+mysql实现的简易BBS论坛
- Java web 购物车Idea工程ServletCartDemo
- java httpclient https或http及文件中转上传
- 基于java坦克大战课程设计报告
- 基于Java的仓库管理系统课程设计报告
- 毕设-基于JSP+SQL Server管理系统
- 数字图像处理Java实现
- 单机版和网络版的Java写的象棋游戏
- modbus4j完整源码
- javaSwing图书管管理系统
- 基于java的邮件系统源代码
- 基于J2EE的网络物流系统
- 超市管理系统——Java源代码
- java 进存销系统
- java实现多媒体播放器
- Java基础知识ppt适合自学中文
- 医院预约挂号系统的设计与实现
- ojdbc6 11.1.0.7.0
- JAVA_点餐系统
- java图书管理系统程序设计
- Algorithms in Java算法书
- 图书管理系统借书还书续借罚金JAVA
- 用于毕设的Java无纸化在线考试系统
- java根据ip获取国家、地区名称,附带
- java模拟淘宝登录源码请看评论,酌情
- Java+Swing学生信息管理系统
- java学生管理系统(.jsp 含Oracle)
评论
共有 条评论