Professional Documents
Culture Documents
File Transfer and Chatqwdhiewqgdfyge
File Transfer and Chatqwdhiewqgdfyge
2. Robust: - Java Programs are said to be robust because they will take
care of memory management and will never crash under any
circumstances.
4. Portable: - Java Programs are Portable that those can be run under
any kind of environment irrespective of the hardware used. This is
known as platform independent.
Packages Used: -
1. The default package to build any program in Java is lang that is used
in developing this system
2. The API to build Graphical User Interface in Java is provided using
the packages awt and swing. This system uses both the packages to
provide GUI based forms.
3. To provide the communication over the network, the package net is
used to develop the Server and Clients.
4. In Java JDBC (Java Database Connectivity) is used to connect to the
database, a special package known as sql is developed for that.
5. The util package in Java is an enhancement of the existing classes.
This package is also used in this system for declaring arrays (Vector),
and to manipulate the strings.
6. The streams that are used to send and receive the data over network
are also utilized in this system, which are in the package of io.
Hardware Used: -
1. Problem Analysis
2. Requirement Specification
To Transfer To Send
File
<<Include>> Message.
Connect To
Server
Initiator Initiator
(User) (User)
Single Multiple
Client Clients
<<Include>>
File Transfer
Initiator Initiator
(User) (User)
Precondition: - Here the Initiator is the user, who wants to send a file to a
single client or multiple clients.
Post condition: - The user gets the acknowledgement that the file has been
reached.
3. Use case & Scenario for specifying the paths.
Source Destination
Path Path
<<Include>>
To Transfer
A File
Initiator Initiator
(User) (User)
Single Multiple
Client Clients
<<Include>>
Disconnect
Client
Initiator Initiator
(User) (User)
Post condition: - The user’s presently connected clients list will be updated.
FEASIBILITY STUDY
Costs: -
Up-front/One-time costs: -
Software
Hardware
Communications
Data Conversion
Training
Ongoing costs: -
Personnel
Software Upgrades
Supplies
Support
Software and Hardware Maintenance
Software Maintenance
Fewer errors that will occur in this system
No training is required to personnel
Better Communication
Better Access of Data
Functional Requirements
Performance Requirements
Design Constraints
Functional Requirements: -
2. In order to send a file then enter the Source & Destination paths
must be entered correctly.
Validation: - If the Source path is entered wrong or not entered, then
an error should be displayed. If the Destination path is wrong then the
client has to be intimated by the server that the path doesn’t exist in
the remote client.
Performance Requirements: -
Design Constraints: -
There are number of factors in client’s environment that may
restrict the choices of a designer. Such factors include,
Activity Diagrams: -
Activity Diagram shows the overall functionality of the system.
Server
Client 1 Client 2
The Information
Is displayed as
Tool tip.
EXIT
2. Activity Diagram for transferring file.
EXIT
4. Activity Diagram for Disconnecting (Active/Passive mode) clients.
EXIT
Sequence Diagrams: -
Updates Client 1
Client 2 Connects
Updates Client1
Updates Client 2
Client 3 Connects
Updates Client1
Updates Client 2
Updates Client 3
2. Sequence Diagram for transferring a file from Client 1 to Client 3.
Here client 3 is a passive mode client, which can only receive a
file/message.
Selects a file
And sends it to the
Client 3.
Server redirects the file to Client3
3. Sequence Diagram for Implicitly disconnecting a single or multiple
clients. Here client 3 is passive mode client, which can only receive a
file/message.
Sends a message
To disconnect
Client 3. Server Disconnects Client 3 forcibly
Updates Client 1
Updates Client 2
Class Diagrams: - The things naturally fall into categories we refer to those
categories as classes. A class is a category or group of things that have
similar attributes and common behavior.
: Client
+ Socket Instance
+ Input Stream
+ Output Stream
+ Host Address
+ Connected Hosts
+ addLabel( )
: Server
+ Socket Instance
+ Input Stream
+ Output Stream
+ Number of
Client
+ Connected Hosts
+ addClient( )
Object Diagram: - An Object is an instance of a class. A specific thing that
has a specific value of the attributes and behavior.
Client
2
Client
Client 3
1
Server
Client
4
Client ….
n
State Transition Diagrams: -
At any given time an object is in a particular state. State Transition
Diagrams are used to represent the states of an object at any particular
instance.
Client Server
Initiated Sends Host Address Initiated
Server in
Listening
State
DATABASE DESIGN
INTRODUCTION: -
Structuring the data is nothing but normalising the data. Normalisation is the
process of simplifying the relationship among the data elements in a record.
E-R Diagram: -
E-R Diagrams are used to represent the relation ship among the
entities. In this system there are only 2 entities that are Server and Client. So
the Entity Relationship Diagram for this system is drawn below,
Here in this system only one table is used which is having 2 fields. The
table is already in First Normal Form. So no need to normalize here.
Even though, some of the normalisation process has been given below,
For testing purpose the test cases are designed in the following format.
Condition: -xxxxxxxxx
Input Criteria: -xxxxxx
Input: - xxxxxxxxxxxx
Result: - xxxxxxxxxxx
1. Test case for ‘Server should run for a client when a client want to
connect to the Server’.
Condition: “The Server must be under running state when a client get
Connected”.
Input Criteria: Any client can connect to Server, which is not running.
Input: Client 1 wants to connect.
Result: Error message “Server Presently Not Running” is displayed.
Source: Form
Source: Killall
Source: ActiveForm
Source: Sendall
Source: Chat
Source: Chatform
Note:
A Automatic
PA Partial Automatic
T Text
ML Multi Line
B Button
S Selection
IMPLEMENTATION/USER INTERFFACE
1.HARDWARE: -
2. Java 2, Unleashed.
Jamie Jaworski.
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
import java.util.*;
import java.sql.*;
class Ftpser
{
public static void main(String ds[])
{
server3 s=new server3();
}
}
class server3 extends Thread
{
ServerSocket ser;
Socket cli;
static int no=0;
static Vector v1=new Vector(10);
static int port=143;
Vector v=new Vector(10);
static Vector donot=new Vector(10);
server3()
{
try
{
ser=new ServerSocket(port);
start();
//setDaemon(true);
}catch(Exception e){System.out.println(e);}
}
public void run()
{
while(true)
{
try
{
cli=ser.accept();
v.insertElementAt(new mul2(cli,this,no),no);
Runtime t=Runtime.getRuntime();
t.gc();
}catch(Exception e){System.out.println(e);}
}
}
String all=str.nextToken("*");
String path=str.nextToken();
System.out.println("The size :"+size);
byte b1[]=new byte[size];
rin.readFully(b1,0,size);
System.out.println("came out");
StringTokenizer str1=new StringTokenizer(all," ");
System.out.println(path);
String mess=sender+" "+"sizel "+size+" "+path;
int i=1;
while(i<str1.countTokens())
{
int rec=server3.v1.indexOf(str1.nextToken().trim());
new sending(rec,b1,mess,ser);
}
}
else
if(msg.indexOf("nopath")>=0)
{
System.out.println("Entered in nopath");
str=new StringTokenizer(msg," ");
str.nextToken();
String rece=str.nextToken();
int x=server3.v1.indexOf(str.nextToken());
ser.send2(x,"nopath in "+rece);
}
Source Code for Activeclient
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.util.*;
import java.sql.*;
public class chatform extends JFrame implements
Runnable,ActionListener,MouseListener
{
JButton send,exit,kill;
JTextArea ta,ta1;
JTextField tf;
JLabel l1;
JScrollPane jsp,jsp1;
DataInputStream rin;
DataOutputStream out;
int n=0;
String user,mess;
JLabel l[]=new JLabel[100];
JPanel p2;
Vector v=new Vector();
Vector tip=new Vector();
//chat c1;
static int z=0;
byte b[]=new byte[50];
form f;
sendall all;
Connection con;
Statement stmt;
ResultSet rs,rs1,rs2;
static int in=0;
public chatform(String user)
{
super("CONNECTED USERS INFORMATION");
this.user=user;
try{
Socket cli=new Socket("localhost",143);
rin=new DataInputStream(cli.getInputStream());
out=new DataOutputStream(cli.getOutputStream());
//InetAddress inet=InetAddress.getLocalHost();
//user=inet.getHostAddress();
byte x[]=("Theusername, "+user).getBytes();
System.out.println(new String(x));
out.write(x,0,x.length);
setSize(600,425);
setLocation(75,75);
show();
Container c=getContentPane();
JPanel p=new JPanel(new BorderLayout());
JPanel p1=new JPanel(new FlowLayout());
p2=new JPanel(new GridLayout(100,1,0,10));
ta=new JTextArea();
tf=new JTextField(50);
ta.setFont(new Font("",Font.BOLD,18));
ta.disable();
int v1=ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS;
jsp=new JScrollPane(ta,v1,h);
p.add(jsp,BorderLayout.CENTER);
p.add(tf,BorderLayout.SOUTH);
send=new JButton("SEND ALL");
exit=new JButton("EXIT");
kill=new JButton("KILL");
p1.add(kill);
p1.add(send);
p1.add(exit);
exit.addActionListener(this);
send.addActionListener(this);
kill.addActionListener(this);
l1=new JLabel(" ALL CONNECTED USERS");
l1.setFont(new Font("helvatica",Font.BOLD,22));
l1.setForeground(Color.darkGray);
/*ta.addMouseListener(new MouseAdapter()
{
public void mouseEntered(MouseEvent me){
ta.disable();
}
public void mouseExited(MouseEvent me){
ta.enable();}
});*/
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:raj");
stmt=con.createStatement();
rs=stmt.executeQuery("select *from users");
rs2=rs;
rs1=rs;
}
catch(Exception e){System.out.println(e);}
rin.read(b);
String str=new String(b).trim();
System.out.println(str);
StringTokenizer s=new StringTokenizer(str," ");
while(s.hasMoreTokens())
{
String t=s.nextToken();
rs1=stmt.executeQuery("select *from users");
int flag=0,i=0;
if(!t.equals("allusers"))
{
ta.append(t+" :Presently Connected "+"\n");
v.addElement(t);
while(rs1.next())
{
i++;
if(t.trim().equals(rs1.getString(1)))
{tip.addElement(rs1.getString(2));flag=1;}
}
if(flag==0)
tip.addElement("Not Updated");
System.out.println("sumitra"+i+" flag"+flag);
}
System.out.println(v.size()+" "+tip.size());
}
for(int i=0;i<100;i++)
{
l[i]=new JLabel("");
p2.add(l[i]);
}
jsp1=new JScrollPane(p2,v1,h);
addlabel();
c.setLayout(new BorderLayout());
c.add(l1,BorderLayout.NORTH);
c.add(p1,BorderLayout.SOUTH);
c.add(jsp1,BorderLayout.EAST);
c.add(p,BorderLayout.CENTER);
show();
Thread t=new Thread(this);
t.start();
}catch(Exception e){System.out.println("anand1 "+e);}
}
if(flag==1)
{
out.flush();
out.write(("nopath "+" "+user+" "+sender).getBytes());
}
}
if(msg.startsWith("captured"))
{
System.out.println("Entered in captured");
System.out.println(msg);
StringTokenizer str=new StringTokenizer(msg," ");
str.nextToken();
str.nextToken();
String s=str.nextToken();
//System.out.println(f.status2.getText());
int ind=v.indexOf(s);
l[ind].setForeground(Color.cyan);
if(in==0)
f.status2.append("File Transfered To System: "+s+"\n");
else
all.f.status2.append("File Transfered To System: "+s+"\n");
}
if(msg.startsWith("nopath"))
{
System.out.println("Entered in nopath");
System.out.println(msg);
StringTokenizer str=new StringTokenizer(msg," ");
str.nextToken();
str.nextToken();
String s=str.nextToken();
//System.out.println(f.status2.getText());
if(in==0)
f.status2.append("Path Not Found In System: "+s+"\n");
else
all.f.status2.append("Path Not Found In System: "+s+"\n");
}
if(msg.endsWith("mustquit"))
{
System.out.println("You have been Forcibly removed from server");
System.exit(0);
}
}
}
}catch(Exception e){System.out.println("anand2 "+e);}
}
void addlabel()
{
System.out.println("The size is"+v.size());
for(int i=0;i<v.size();i++)
{
String t=" "+(String)v.elementAt(i)+" ";
System.out.println(t);
l[i].setFont(new Font("",Font.BOLD,16));
l[i].setText(t);
l[i].setToolTipText((String)tip.elementAt(i));
if(user.equals((String)v.elementAt(i)))
{l[i].setForeground(Color.red);
continue;}
if(!l[i].getForeground().equals(Color.cyan))
l[i].setForeground(Color.blue);
l[i].addMouseListener(this);
}
for(int j=v.size();j<10;j++)
{l[j].setText("");l[j].removeMouseListener(this);l[j].setToolTipText("");}
}
public void mousePressed(MouseEvent me){}
public void mouseEntered(MouseEvent me)
{setCursor(Cursor.HAND_CURSOR);}
public void mouseExited(MouseEvent me)
{setCursor(Cursor.DEFAULT_CURSOR);}
public void mouseClicked(MouseEvent me){
if(me.getClickCount()==1)
{
JLabel l=(JLabel)me.getComponent();
in=0;
f=new form(this,l.getText(),user,null);
}
}
public void mouseReleased(MouseEvent me){}
public static void main(String ds[])
{
new chatform(ds[0]);
}
}
INDEX
S.NO CONTENTS PAGE NO
1 ABSTRACT
2 INTRODUCTION
2.1.INTRODUCTION TO ORGANIZATION
2.2.INTRODUCTION TO ENVIRONMENT
2.2.1.SOFTWARE USED
2.2.2.HARDWARE USED
03 REQUIREMENT ANALYSIS
3.1.PROBLEM ANALYSIS
3.1.1.SCENARIOS & USE CASES
3.2.FEASIBILITY STUDY
3.2.1.TECHNICAL FEASIBILITY
3.2.2.OPERATIONAL FEASIBILITY
3.2.3.ECONOMIC FEASIBILITY
3.2.3.1.COST-BENEFIT ANALYSIS
3.3.PREPARATION OF REQUIREMENT
SPECIFICATION
3.3.1.SOFTWARE REQUIREMENT
SPECIFICATION
04 SOFTWARE DESIGN
4.1.OBJECT ORIENTED DESIGN METHODOLOGY
4.1.1.INTRODUCTION
4.1.2.DESIGN TOOLS UTILISED
4.1.2.1.ACTIVITY DIAGRAMS
4.1.2.2.SEQUENCE DIAGRAMS
4.1.2.3.CLASS DIAGRAMS
4.1.2.4.OBJECT DIAGRAMS
4.1.2.5.STATE TRANSITION DIAGRAMS
05 DATABASE DESIGN
5.1.INTRODUCTION
5.2.E-R DIAGRAMS
5.3.NORMAL FORMS IMPLEMENTED
5.4.TABLE DESCRIPTIONS
S.NO CONTENTS PAGE NO
06 TESTING
6.1.STRUCTURAL TESTING (WHITE BOX)
6.1.1.INTRODUCTION
6.1.2.LIST OF TEST CASES PREPARED
6.2.FUNCTIONAL TESTING (BLACK BOX)
6.2.1.INTRODUCTION
6.2.2.LIST OF TEST CASES PREPARED
07 FORMS DESIGN
7.1.INPUT FORMS DESIGN
7.2.OUTPUT FORMS DESIGN
08 IMPLEMENTATION/USER INTERFACE
8.1.ALGORITHMIC / NAVIGATIONAL DESCRIPTION
09 CONCLUSION
10 BIBILIOGRAPHY
11 APPENDIX
11.1.ANNEXURE-I (SCREEN LAYOUTS)
11.2.ANNEXURE-II (SAMPLE CODE)
11.3.ANNEXURE-IV (GLOSSARY: ABBREVATION &
ACRONYMS)
ABSTRACT