how to write function of copy from one to another location in this code

how to write function of copy from one to another location in this code

I need to write a code to copy a file from one location to another using browse button in it. i have written code for the browse button. please help me to add code for copy using swing!! thanks in advance.**

/*
 For Browse button. 
 */
package com.design;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JTextField;

public class Browse extends JFrame implements 

ActionListener {

JButton button1, button2 ;
JTextField field1, field2;

public Browse () {
this.setLayout(null);

button1 = new JButton("Browse");
field1 = new JTextField();

field1.setBounds(30, 50, 200, 25);
button1.setBounds(240, 50, 100, 25);
this.add(field1);
this.add(button1);

button2 = new JButton("Copy");
button2.setBounds(150, 150, 100, 25);
this.add(button2);

button1.addActionListener(this);
setDefaultCloseOperation

(javax.swing.WindowConstants.EXIT_ON_CLOSE

);



}

public void actionPerformed(ActionEvent e) {
Chooser frame = new Chooser();
field1.setText(frame.fileName);

}

public static void main(String args[]) {

Browse frame = new Browse ();
frame.setSize(400, 300);
frame.setLocation(200, 100);
frame.setVisible(true);


}
}

class Chooser extends JFrame {

JFileChooser chooser;
String fileName;

public Chooser() {
chooser = new JFileChooser();
int r = chooser.showOpenDialog(new JFrame());
if (r == JFileChooser.APPROVE_OPTION) {
fileName = chooser.getSelectedFile().getPath();
System.out.println(fileName);
}
}
}
View Answers

March 4, 2013 at 5:08 PM

hi friend,

Please visit the link, may this will be helpful for you

http://www.roseindia.net/java/example/java/io/MovingFile.shtml

Thanks.









Related Tutorials/Questions & Answers:
how to write function of copy from one to another location in this code
how to write function of copy from one to another location in this code  I need to write a code to copy a file from one location to another using... to add code for copy using swing!! thanks in advance.** /* For Browse button
how to copy file from one directory to another in java with examples
how to copy file from one directory to another in java with examples  how to copy file from one directory to another in java with examples? I want... copy from one directory to another in java. Thanks
Advertisements
File copy from one directory to another in java
File copy from one directory to another in java  I am trying to find very good code example for copying a file from one directory to another... from a directory to another directory. How to achieve this? Is there any API
How to copy files from one folder to another based on lastmodified date - Java Beginners
Copy files from one folder to another  How to copy files from one folder to another based on lastmodified date
Copy data from one JTextField to another JTextField
, you will learn how to copy the data from one JTextField into another... Copy data from one JTextField to another JTextField... data into first JTextfield and select the entered text, right click, copy
File copy from one drive to another. - Java Beginners
File copy from one drive to another.  I want to copy a .mp3 file from one drive(let d: drive)to another drive(let e: drive) in my Windows XP. How can I do
How to copy files from one folder to another based on lastmodified date - Java Beginners
How to copy files from one folder to another based on lastmodified date  I have to make a simple utility to copy files from a folder to another folder in the same hierarchy, without overwriting the existing.  hiimport
Copy one file into another
Copy one file into another In this section, you will learn how to copy content of one file into another file. We will perform this operation by using...;This string is copied from one file to another\n"); bf.close(); InputStream
how to copy files from remote location to local using java?
how to copy files from remote location to local using java?  I want to copy all files from shared folder to local. Please help
how to pass a string from one class to another
how to pass a string from one class to another  hi all, Good morning... string from one class to another. import java.util.*; class A{ static String... string from one class to another. import java.io.*; class Class1 { public
How to forward the control from one jsp to another?
How to forward the control from one jsp to another?  Hi! This is Prasad Jandrajupalli. I have the 3 JSP's, but I want communicate with each... is not communicate with the Third JSP. I want forward the control from first jsp to second
How to navigate from one jsf to another in eclipse
How to navigate from one jsf to another in eclipse  Hi there is my jsf code... <%@ page language="java" contentType="text/html; charset... using the above code for my welcome page which ask for user name and after
How to write content of one file to another file.
the associated stream. void write(int b) Method writes one... the use of CheckedOutputStream class. The CheckedOutputStream class is from...; In this example we will open a file and then write the content in new file
swings:how to link from one form to another form
swings:how to link from one form to another form  how to link from one form to another form
Java - Copying one file to another
;    This example illustrates how to copy contents from one... for buffering the contents of one file and write to another specified file from... copies one file to another file. We will be declaring a function called copyfile
how to pass an array from one jsp to another jsp - JSP-Servlet
how to pass an array from one jsp to another jsp  hi friedns, can any One tell me how to send an array from one jsp to another jsp,pls any one send the code for this.also porvid the code how to retrive the arry in another jsp
How to write content of one file to another file and calculate checksum for accuracy.
) Method writes one byte of data onto the stream  Code...; compute checksum value as data read from associated stream... on the output stream.  In this Example, we will write the content of a file
How to pass variable from one class to another in java
How to pass variable from one class to another in java  How to pass variable from one class to another in java?   Example: public class...; } } //Another class Class2. public class Class2 { public static void main(String
i want to copy files from one machine to other using java and the code will be running on third machine
i want to copy files from one machine to other using java and the code will be running on third machine  i want to copy some files from one machine... machine say 'c'. So , can you help me on this that how can i do this using
how to go from one frame to another frame in swings - Java Beginners
how to go from one frame to another frame in swings  Hi, My task is to go from one frame to another.......... let us think that iam having two... this task in swings or applet......... i have gone through one example of login
Copy One Database Table to Another
Copy data from one database table to another! 4 row(s)affected... Copy One Database Table to Another   ... to another database table. That means we copy one table to a different table
How To Pass data from one GUI to another in java swing
How To Pass data from one GUI to another in java swing  I'm new to java and part of our assignment is to build a GUI and display a result set from data input. I'm stuck at how to get the user's input from JTextFields and combobox
How to copy an jpeg image from one folder to other folder using jsp
How to copy an jpeg image from one folder to other folder using jsp  How to copy an image from one folder to another folder using jsp
java program to copy the contents of one folder to another folder
java program to copy the contents of one folder to another folder  java program to copy the contents of one folder to another folder   Have a look at the following link: Java Copy one folder to another
how to use one form out of multiple form from one jsp to another jsp
how to use one form out of multiple form from one jsp to another jsp  Hi All. please give me your valuable advise for below requirement.. I have... one form from abc.jsp as it is to another .jsp(say def.jsp).Your advise
Copying an array to another
Copying an array to another       Java Copy Array Example:In this tutorial, you will learn how to copy data from one array to another. Here, providing you an example with code
calling one jsp from another jsp page
calling one jsp from another jsp page  need coding for calling one jsp from another jsp including the xml file.Its urgent
java program to take the backup of folders and copy the folder in different location without deleting the existing one
the backup of folders and copy the folder in different location without deleting the existing one   Have a look at the following link: Java Copy one folder...java program to take the backup of folders and copy the folder in different
How to copy an jpeg image from one folder to other folder using jsp
How to copy an jpeg image from one folder to other folder using jsp  hello, i am creating photo gallery where from admin side i allow admin to browse... be in my image folder...so,How to copy an jpeg image from one folder to other
how to scrape the data from one website another website using html dom parsing in php
how to scrape the data from one website another website using html dom parsing in php  " how to scrape the data from one website another website using html dom parsing in php" i'm trying this one .please provide code for me
update one table from another table
update one table from another table  hello, i need to update one table fields by using another table fields. I have to tables Products.... for example TotalQuantity field from Products table should be updated if i
copying data from one table to another
copying data from one table to another  i need to copy data from one table to another table.. i.e the 1st eid of employee table must be copied... and so on... i need these querys to use in my JSP code
how to move curosr from one text field to another automatically when the first textfield reaches its maximum length
how to move curosr from one text field to another automatically when the first textfield reaches its maximum length  how to move curosr from one text field to another automatically when the first textfield reaches its maximum
how to pass arraylist data from one jsp to another jsp - JSP-Servlet
how to pass arraylist data from one jsp to another jsp  hi to all iam... the following >XXX/ ? is required to send a value from one jsp to another... to receive all employee id's that are retrived from the database in the first jsp
passing data from one jframe to another
passing data from one jframe to another  I have two JFrame,built by using the GUI Editor netbeans 6.9.i have to pass a data from a Jtextfield in the first Jframe to another JLabel in the other JFrame.Can you please help me,how
How to copy a file in java
. In another way we can copy using File I/o Stream. Example:  Java Code to copy...How to copy a file in java In this section you will learn about how to copy a content of one file to another file. In java, File API will not provide any
to bring checked data from one page to another
to bring checked data from one page to another  thanks for your help... there is one jsp page , on it there is a link, on click of which it is opening second... fetching data from the database on second jsp page with checkbox corresponding each
Moving file or directory from one directory to another
Moving file or directory from one directory to another... directory is moved from one directory to another directory. This program... from one directory to another. In this section an example is given
Drag and Drop components from one frame to another frame
button etc.) from one frame to another frame. In this code we have used... Drag and Drop components from one frame to another frame..., user can drag and drop component from one to another frame. Download Source
how to write code for this output?
how to write code for this output?   1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
problem in sending data from one ip to another ip in JAVA
problem in sending data from one ip to another ip in JAVA  Hi guys . this is naveen kumar...i need a help. i want to connect one ip to another ip... device in JAVA. i know how to ping but don't how to send the msg's to another IP
retrieving of data from one jsp to another jsp - JSP-Servlet
retrieving of data from one jsp to another jsp  using jsp i m displaying a table ,in table i m displaying a radio button then values like id,name etc... Friend, Try the following code: 1)Home.jsp: function transfer(id
calling one jap page from another jsp page
calling one jap page from another jsp page  i created a button in one jsp page i need to call another jsp page as an action to that button. so how can i call.. plz any one explain. its urgent
Pass cookie from one site to another within the same domain
Pass cookie from one site to another within the same domain  Hi, I want to pass a cookie from one website to another within the same domain... out with the code?. Thanks Priya
how to change password into one jsp to another jsp
how to change password into one jsp to another jsp  i have two jsps in one jsp i give one password and confirm password, in another jsp i want change my password compare with 1st jsp how to write code please give me answer?  
How i write a function/method in jsp?
How i write a function/method in jsp?  How write the function/method in jsp? Using that method i can retrieve the value coming from database. give.... And the details come from different table and id is store in user table. I hope you all
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  1) Copy one file content to other? 2) Count the number of words in a file
how to use string of one class into another Class
how to use string of one class into another Class  I created textField(JTextField t1=new JTextField();(it is in ClassA. The input of this textField i.e t1.getText() is to be used in different(another Class say in ClassB. How can
retrieve the records from one table to another table by using cursors
retrieve the records from one table to another table by using cursors  ... from one table to another table by using cursors.The following is my procedure and tables.After execution it insert one extra record to another table. empproc
take data from one table and insert same in another
take data from one table and insert same in another  I want to know when a new field update in table and the same data has to update in another table

Ads