SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-09-2009, 08:51 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Help with moving file in Java using renameTo()

I am trying to move files to a new directory in java and I am having issues as I am not very familiar with creating/moving directories/files in java.

I am using renameTo() here is an example of code

File = ("pic.jpg")
Dir = ("fanartfolder")

I then use

boolean filecopied = File.renameTo(new File(Dir,File.getName()));

I then check with the boolean wether or not it is done. My question is does the directory have to exist or do I need to create it in java as well before copying files into it? or will it create the directory when I copy files regardless?

TIA
Reply With Quote
  #2  
Old 10-09-2009, 09:41 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Okay answered my own question the directory has to exist. No off to figure out how to create the directory
Reply With Quote
  #3  
Old 10-09-2009, 09:49 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Okay I keep getting failures on trying to create directorys I am using the following

Code:
String dir = "directory path" (ie "\\\server\\movies\\test")
File fdir = new File(dir);
if (fdir.isDirectory() == false){
boolean dirmade = fdir.mkdir();

I check the return of dirmade and am always getting false.
Reply With Quote
  #4  
Old 10-09-2009, 09:58 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Jeff helped me with this for those interested i needed to check again existance ( exist() )not isdirectory.
Reply With Quote
  #5  
Old 10-09-2009, 09:19 PM
bastafidli bastafidli is offline
Sage Expert
 
Join Date: Dec 2007
Location: Charlottesville, VA
Posts: 728
Yo may also want to look at fdir.mkdirs(); (S at the end)
__________________

TV: Samsung UN46D8000
Server: Intel Core i3 540, 4G RAM, Matrox G450, 70GB EXT3 encrypted software RAID1 system drive, 1TB XFS tv recording drive, 2TB EXT3 encrypted data drive mirror across 2 machines, 2TB EXT3 encrypted media drive mirror across 2 machines, CentOS 6 64 bit, Experimenting with DNLA servers
1Gb wired network
Disconnected after G day[HD 100 Media Extender, Placeshifter 7.x, SageTV 7.x, HDHomeRun]
Reply With Quote
  #6  
Old 10-10-2009, 07:18 AM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by bastafidli View Post
Yo may also want to look at fdir.mkdirs(); (S at the end)
I took a look at that thanks.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
java file access from an extender jphipps SageTV Studio 7 06-11-2009 08:55 PM
Feature Request: Archived file moving maninblack_30 SageTV Beta Test Software 0 12-01-2008 03:59 PM
Java error - file attached stani SageTV Software 0 11-05-2007 10:33 AM
Screwed up moving files (java error) k9k9 SageTV Software 2 04-20-2006 07:00 PM
Moving video file to another disk hamptonhills SageTV Software 1 11-29-2003 09:49 AM


All times are GMT -6. The time now is 05:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.