Results 1 to 3 of 3
  1. #1
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    301
    Blog Entries
    1
    Rep Power
    4

    Default how to get exact file path

    Hi!
    I wants to get exact file for my program,
    i add my problematic code with this thread,
    so many i choose a correct file by file chooser.
    But it is not taken its file please help my brother..,



    Java Code:
    
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class FileSelect extends JFrame implements ActionListener {
        JLabel label_1;
        JLabel label_2;
        JLabel label_3;
        TextField textfield_1;
        JLabel label_4;
        JTextField textfield_2;
        JButton button_3;
        JButton button_2;
        JButton button_1;
        
        Panel p;
        JButton button_4;
        FileDialog fd1;
        Dialog d;
    
        String s,temp;
        String s1,s2;
        
    
        public FileSelect() {
    
            
            FileSelectLayout customLayout = new FileSelectLayout();
    
            getContentPane().setFont(new Font("Helvetica", Font.PLAIN, 12));
            getContentPane().setLayout(customLayout);
    
            label_1 = new JLabel("DATA SECURITY USING CRYPTOGRAPHY AND STEGANOGRAPHY");
            getContentPane().add(label_1);
    
            label_2 = new JLabel("DES  Encryption:-");
            getContentPane().add(label_2);
    
            label_3 = new JLabel("Enter Encryption Key :-");
            getContentPane().add(label_3);
    
            textfield_1 = new TextField("");
            getContentPane().add(textfield_1);
    
            label_4 = new JLabel("Select the File :-");
            getContentPane().add(label_4);
    
            textfield_2 = new JTextField("");
            getContentPane().add(textfield_2);
    
            button_2 = new JButton("Browse");
            getContentPane().add(button_2);
    
            button_1 = new JButton("Start Encryption");
            getContentPane().add(button_1);
    
            button_3 = new JButton("<<Back");
            getContentPane().add(button_3);
    
            button_4 = new JButton("OK");
            getContentPane().add(button_4);
    
            d=new Dialog(this,"Error with Entry !");
            
    
            
            button_1.addActionListener(this);
            button_2.addActionListener(this);
            button_3.addActionListener(this);
            button_4.addActionListener(this);
            
            textfield_1.setEchoChar('*');
    
            fd1=new FileDialog(this,"Open the file",FileDialog.LOAD);
    
            d=new Dialog(this,"mistake in Entry");
            d.setSize(100,100);
            p=new Panel();
            button_4 = new JButton("Ok");
            button_4.addActionListener(this);
            p.add(button_4);
            d.add(p);
    
            
            addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            });
        }
    
        public void actionPerformed(ActionEvent e)
        { 
            if (e.getSource()==button_1) // Start Encryption
            { // if 1
            
    
                // Clear the temp Files
                
                File f11=new File("../CryptoStegno/src/TwoOfAbove/test.txt");
                File f22=new File("../CryptoStegno/src/TwoOfAbove/dec1.txt");
                f11.delete();
                f22.delete();
    
                //-----------------------------------------------------------------------//
    
                s1=textfield_2.getText(); // file
                s2=textfield_1.getText(); // key
                System.out.println(s2); // key1
                System.out.println(s1); // File
                
                File f=new File(s1);
                int i1=s2.length();
                             
                int k1=1;
                             
                int flag=0;
                 
                if(f.isFile())                              :(devil):  [SIZE=7][FONT=impact] (here is my problem Brother)[/FONT][/SIZE]
                { // 2
                    k1=0; 
                } // 2
                System.out.println("\n this "+k1);
                if(i1!=8 || k1==1) // if error in entry
                { // 3
                    d.show();
                } // 3
                
    //--------------------------------TRIPLE-DES STEP1 START--------------------------------------//
                
                else
                {    // else 1
                    System.out.print("test\n");
                    if(s2.length() != 8)
                    { // 4
                        System.out.print("Error on 116\n");
                    } //4
                    else 
                    {        // else at 136
            
                        char key[]=new char[8];
                        key[0]=s2.charAt(0);



    I am waiting for your ans pls help me..,

  2. #2
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    301
    Blog Entries
    1
    Rep Power
    4

    Default Re: how to get exact file path

    i have correct the error myself,
    Thank you gentles..,

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,044
    Blog Entries
    7
    Rep Power
    23

    Default Re: how to get exact file path

    Quote Originally Posted by raj.mscking@gmail.com View Post
    i have correct the error myself,
    Thank you gentles..,
    Good; why not show your solution here so other readers may benefit from it?

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

Similar Threads

  1. file path
    By billq in forum New To Java
    Replies: 2
    Last Post: 04-11-2010, 05:47 PM
  2. ant with a jar file in path to run
    By javastuden in forum Advanced Java
    Replies: 0
    Last Post: 02-22-2010, 06:59 AM
  3. file path
    By ras_pari in forum Advanced Java
    Replies: 2
    Last Post: 10-12-2009, 11:25 AM
  4. file path
    By Arsench in forum New To Java
    Replies: 7
    Last Post: 10-30-2008, 06:39 AM
  5. Replies: 7
    Last Post: 10-28-2008, 02:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •