how to convert java code to pseudo code

Jul 24 2017 11:37 PM
Main Class:
public class IPath {
public static void main(String[] args) {
ipath_reconstrucor.main(null);
WSN_Server.main(null);
KeyGenerator.main(null);
Source.main(null);
Receiver.main(null);
Results.main(null);
}
}
Source.java:
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class Source extends JFrame implements ActionListener {
private static final long serialVersionUID = 2L;
Font f = new Font("times new roman", Font.BOLD, 15);
JPanel p = new JPanel();
JTextArea ta = new JTextArea();
JScrollPane pane = new JScrollPane();
JTextField tf1 = new JTextField(), tf2 = new JTextField(),
tf3 = new JTextField();
JButton b1 = new JButton("Browse"), b2 = new JButton("Upload"),
b3 = new JButton("Reset");
Source() {
p.setLayout(null);
p.setBackground(Color.WHITE);
tf1.setFont(f);
tf2.setFont(f);
b1.setFont(f);
b2.setFont(f);
b3.setFont(f);
ta.setRows(10);
ta.setColumns(10);
ta.setFont(f);
pane.setViewportView(ta);
tf1.setBounds(50, 130, 150, 25);
tf2.setBounds(250, 130, 150, 25);
pane.setBounds(50, 175, 450, 350);
b1.setBounds(65, 550, 125, 30);
b2.setBounds(215, 550, 125, 30);
b3.setBounds(365, 550, 125, 30);
ImageIconim1=new ImageIcon(this.getClass().getResource("ServiceProvider.PNG"));
JLabel image = new JLabel();
image.setIcon(im1);
image.setBounds(50, 0, 1110, 100);
ImageIconim=new ImageIcon(this.getClass().getResource("DataOwnerFront.png"));
JLabel image11 = new JLabel();
image11.setIcon(im);
image11.setBounds(500, 140, 1110, 400);
p.add(tf1);
p.add(tf2);
p.add(pane);
p.add(b1);
p.add(b2);
p.add(b3);
p.add(image);
p.add(image11);
add(p);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
}
public static void main(String[] args) {
Source d = new Source();
d.setBounds(50, 50, 900, 650);
d.setTitle("Source::Efficient Inter connectivity pathway reached in wireless sensor networks");
d.setVisible(true);
}
@SuppressWarnings({"static-access", "resource"})
public void actionPerformed(ActionEvent e) {
JOptionPane op = new JOptionPane();
if (e.getSource() == b1) {
JFileChooser chooser = new JFileChooser();
try {
File f = new File(new File("filename.txt").getCanonicalPath());
chooser.setSelectedFile(f);
} catch (IOException e1) {
}
int retval = chooser.showOpenDialog(b1);
if (retval == JFileChooser.APPROVE_OPTION) {
File field = chooser.getSelectedFile();
tf1.setText(field.getName());
tf2.setText(Integer.toString(new KeyGenerator().getKeys()));
}
File curFile = chooser.getSelectedFile();
try {
FileInputStream fstream = new FileInputStream(curFile);
DataInputStream ins = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(
ins));
StringBuffer buffer = new StringBuffer();
String strLine;
while ((strLine = br.readLine()) != null) {
buffer.append(strLine + "\n");
}
ta.setText(buffer.toString());
ta.setEditable(false);
tf1.setEditable(false);
tf2.setEditable(false);
} catch (Exception e1) {
System.err.println("Error: " + e1.getMessage());
}
}
if (e.getSource() == b2) {
try {
String ip=op.showInputDialog(null,"Enter IP Address");
AES_ENC_DEC enc= new AES_ENC_DEC();
String data = ta.getText();
String fname = tf1.getText().substring(0,
tf1.getText().lastIndexOf("."));
String ext = tf1.getText().substring(
tf1.getText().lastIndexOf("."), tf1.getText().length());
int x = data.length();
int len = x / 5;
String p1 = data.substring(0, len);
String p2 = data.substring(len, len * 2);
String p3 = data.substring(len * 2, len * 3);
String p4 = data.substring(len * 3, len * 4);
String p5 = data.substring(len * 4, len * 5);
Socket socket = new Socket(ip, 5000);
SimpleDateFormat sdfDate = new SimpleDateFormat("dd/MM/yyyy");
SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm:ss");
Date now = new Date();
String strDate = sdfDate.format(now);
String strTime = sdfTime.format(now);
String dt = strDate + " " + strTime;
String sql = "insert into owner values ('" + tf1.getText()
+ "','" + tf2.getText() + "','" + dt + "')";
DBConnection.getConnection().createStatement().executeUpdate(
sql);
new FileOutputStream("Owner/" + fname + "1" + ext).write(p1
.getBytes());
new FileOutputStream("Owner/" + fname + "2" + ext).write(p2
.getBytes());
new FileOutputStream("Owner/" + fname + "3" + ext).write(p3
.getBytes());
new FileOutputStream("Owner/" + fname + "4" + ext).write(p4
.getBytes());
new FileOutputStream("Owner/" + fname + "5" + ext).write(p5
.getBytes());
DataOutputStream dos = new DataOutputStream(socket
.getOutputStream());
dos.writeUTF(tf1.getText());
dos.writeUTF(tf2.getText());
dos.writeUTF(enc.encrypt(p1));
dos.writeUTF(enc.encrypt(p2));
dos.writeUTF(enc.encrypt(p3));
dos.writeUTF(enc.encrypt(p4));
dos.writeUTF(enc.encrypt(p5));
op.showMessageDialog(null, "File Uploaded SuccessFully");
} catch (Exception ex) {
System.out.println(ex);
}
}
if (e.getSource() == b3) {
tf1.setText("");
tf2.setText("");
ta.setText("");
tf1.setEditable(true);
tf2.setEditable(true);
ta.setEditable(true);
}
}
}
Database Connection:
import java.sql.Connection;
import java.sql.DriverManager;
public class DBConnection {
static Connection con;
static Connection getConnection() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=src\\Database.mdb");
} catch (Exception e) {
e.printStackTrace();
}
return con;
}
}

Attachment: java_code.rar

Answers (2)