Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-19-2008, 05:31 PM
Member
 
Join Date: Jun 2008
Posts: 5
selvin_raj is on a distinguished road
Requesting help in copy paste of folder similar to windows.
Dear All,

I need help in copy pasting folder similar to windows, that is when I copy and paste a folder repeatedly ; the pasted folder name should be as follows.

First time: "copy of new folder"
Second time: "copy of (1) new folder"
Thrid time: "copy of (2) new folder"


I have the basic code to copy a folder, I have hard coded "copy of" text before copied folder. Following is the code please help me.


public Boolean copyConfiguration(String configurationName) throws FileNotFoundException, IOException
{

boolean isCopied = false;

ResourceBundle resourceBundle = null;
ResourceBundle resourceBundleServer = ResourceBundle.getBundle( Constants.ATTEST_SERVER_PROPERTY_FILE );
resourceBundle = ResourceBundle.getBundle( Constants.MESSAGES_PROPERTY_FILE, Language.getInstance( ).getLocale( ) );
String configurationPath = resourceBundleServer.getString("configurationPath" ) + "/data/";
String originalConfiguration = configurationPath + File.separator + configurationName;
String ConfigurationTobeCopied = configurationPath + File.separator + File.separator +"copy_of_" +configurationName;
File newDestination = new File(ConfigurationTobeCopied);
File sourceConfiguration = new File(originalConfiguration);
ConfigurationFileFilter tempFileFilter = new ConfigurationFileFilter();
File[] sourceConfigurationFiles = sourceConfiguration.listFiles();

FileChannel in = null, out = null;

try
{

if( !newDestination.exists( ) ) // If the configuration does not exists.
{
newDestination.mkdirs( );
}

for ( int count = 0; count < sourceConfigurationFiles.length; count++ )
{
if ( sourceConfigurationFiles[count].isFile( ) )
{

if(sourceConfigurationFiles[count].getName().compareToIgnoreCase("file1.xml") == 0)
{
in = new FileInputStream( sourceConfigurationFiles[count] ).getChannel( );
out = new FileOutputStream( newDestination + File.separator + sourceConfigurationFiles[count].getName( ) ).getChannel( );
long size = in.size();
MappedByteBuffer buf = in.map(MapMode.READ_ONLY, 0, size);
out.write( buf );
}
else if (sourceConfigurationFiles[count].getName().compareToIgnoreCase("file2.xml") == 0)
{
in = new FileInputStream( sourceConfigurationFiles[count] ).getChannel( );
out = new FileOutputStream( newDestination+File.separator+sourceConfigurationF iles[count].getName( ) ).getChannel( );
long size = in.size();
MappedByteBuffer buf = in.map(MapMode.READ_ONLY, 0, size);
out.write( buf );
}


}
}

isCopied = true;
}
finally
{
if ( in != null ) in.close();
if ( out != null ) out.close();

}

return isCopied;
}

Regards,
Selvin

Last edited by selvin_raj : 06-23-2008 at 08:48 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-23-2008, 08:46 AM
Member
 
Join Date: Jun 2008
Posts: 5
selvin_raj is on a distinguished road
Is there any one with the solution?
Is there any one with the solution?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i copy a folder from one place to another.. rajeshgubba New To Java 4 06-14-2008 04:21 AM
Java Application Interface similar with Windows Themes Heracles Choe AWT / Swing 9 05-02-2008 05:47 AM
Copy n' Paste in JEditorPane wraps text in new css..? Sam AWT / Swing 0 02-06-2008 05:55 PM
java copy paste cut and undo functions Mr tuition AWT / Swing 1 12-09-2007 02:02 AM
How to implement Cut and Paste Jamie AWT / Swing 2 05-31-2007 08:15 PM


All times are GMT +3. The time now is 12:20 PM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org