Trying to get args[] to behave themselves!

Hi Everyone,
I am having some fun trying to make my program totally portable. I am working with File objects and they are not behaving exactly the way I would like.
My program takes a source directory, which is packed full of pictures, and then uses each of these pictures in an automated manner which results in an html page being produced for each picture.
I am trying to allow the program to run totally from the command line with two arguments, one the source directory and one the destination directory.
So when running my program, you would do something like this:
C:\MyJava>java -cp . auto.Initialize_Program C:\Pictures C:\HTML
I use the (String[] args) array to import the two parameters into my program.
It is past this point that the fun starts, when creating a File object in my IDE I used the following code, which is totally functional:
File textFile = new File("C:\\Pictures\\"+final_file_name+".htm");In the above code snippet the "C:\\Pictures\\" section of code points to my destination directory and the final_file_name variable names each file in the destination (of course with a ".htm" extension).
When I try to use the command line arguments, e.g.:
File textFile = new File(args[0] + final_file_name + ".htm");I end up with a whole bunch of html files called PicturesXYZ.htm (where XYZ is the various file names) in the root directory.
Basically the section that used to point to the destination directory is now becoming part of the file name. I have experimented with the pathSeperator() method of class File to no avail.
I need to find some way of telling the program that the args[0] part is in fact a destination directory and not part of the file name. Does anybody have any suggestions as to how I could go about doing this?
Any help would be super.
Regards
Davo

C:\MyJava>java -cp . auto.Initialize_Program C:\Pictures C:\HTML
File textFile = new File(args[0] + final_file_name + ".htm");args[0] doesn't end in a backslash, and final_file_name doesn't begin with a filename. So obviously, you end up with filenames like "C:\PicturesXYZ.htm". To avoid this, you can either add a backslash in the concatenation (or use File.pathSeparator, to be more platform independent:)
File textFile = new File(args[0] + File.pathSeparator + final_file_name + ".htm");Or, you can make a File object representing the directory, and use that as input to the File constructor when makeing the textFile object:
File dir = new File(args[0]);
File textFile = new File(dir, final_file_name + ".htm");

Similar Messages

  • My divs won't behave themselves....

    I am trying to to put two divs within another div and I can't get them to behave...
    Imagine a two smaller divs contained by a larger div.
    I want an image in one of the small boxes to float left and then in the smaller box floating right  I want text floating to the right of the image.
    No matter what I do, the text won't go up beside the image.  It wants to go beside the image but only start at the bottom of the image.
    I am sure the boxes are within the larger box and I am sure that the widths of the two small boxes are smaller than the width of the bigger box. 
    (I am creating classes that define the size and position of the divs... am I missing a setting?)
    Anybody have this problem before and know a solution?
    Thanks...

    If you get the maths correct - works like a charm - no need for that extra <div> surrounding the two small floated <divs>
    <!DOCTYPE HTML">
    <html>
    <head>
    <meta http-equiv="charset=UTF-8">
    <title>Untitled Document</title>
    <style>
    .classifiedbox {
    width: 875px;
    padding-top: 5px;
    padding-right: 5px;
    padding-bottom: 5px;
    padding-left: 5px;
    border: thin solid #000000;
    .classifieddescription {
    height: 35px;
    padding-top: 2px;
    padding-right: 2px;
    padding-bottom: 2px;
    padding-left: 2px;
    text-align: center;
    font-weight: bold;
    font-size: 24px;
    .classifiedpic {
    width: 260px;
    height: 260px;
    padding-top: 5px;
    padding-right: 5px;
    padding-bottom: 5px;
    padding-left: 5px;
    .classifiedbox div div {
    .classifiedtextdes {
    width: 595px;
    float: left;
    padding-top: 5px;
    padding-right: 5px;
    padding-bottom: 5px;
    padding-left: 5px;
    text-align: left;
    text-indent: 10px;
    font-size: 18px;
    .classifiedobjectbox {
    float: left;
    width: 270px;
    height: 265px;
    .classifiedcontactbox {
    width: 875px;
    padding-top: 5px;
    padding-right: 5px;
    padding-bottom: 5px;
    padding-left: 5px;
    clear: both;
    </style>
    </head>
    <body>
    <div class="classifiedbox">
    <div class="classifieddescription">Description Goes Here</div>
    <div class="classifiedobjectbox"><img src="swapshop/0001/mccarverRound.png" alt="" class="classifiedpic"/></div>
    <div class="classifiedtextdes">This is a round coffee table made out of scratchy stuff that I don't know what it is. It's great for a large living room. You can tell from the magazine pictured how large it is.</div>
    <div class="classifiedcontactbox">Contact box
    <div>Phone #</div>
    <div>Email</div>
    </div>
    </div>
    </body>
    </html>

  • Trying to get Anarmorphic footage in 16 X 9 Aspect ratio from PAL footage

    Hi, I am currently doing some tests - having bought a new camera, the HVX-201 AE. I was trying to get a 16 X 9 Aspect Ratio on my finished test footage. I shot using DV Tape, using several options, the squeeze, letterbox and normal. I then captured using DV PAL Anamorphic..
    On the timeline, it looks fine, with grey on top and below, with no black letterboxes, except for the section with letterbox format on. However, when I export to Quicktime, using the DV PAL 48hz Anamorphic codec, it keeps being saved as a quicktime file with 720 X 576 resolution. Is there any way for it to be 16 X 9? Do I have to use another codec or will it always be in a 5:4 aspect ratio no matter what I do?
    Or is it that when a TV which can play in 16 X 9 detects it, then it shows up as a 16 X 9 picture?
    Thanks for the help. I'm really confused.
    Cheers.

    That's what anamorphic means, it's a 16:9 image stored in a 4:3 frame. You maintain that throughout the post process and any dvd creation in order to utilise the maximum resolution available in sd. When you author the dvd it flags the footage as anamorphic, telling any dvd player you play it in to output it appropriately according to the way it's set up. If your dvd player is not set up properly for the monitor it's connected to it won't work correctly and you'll either see a vertically stretched image with no letterbox (4:3 monitor with dvd player set for a 16:9 monitor) or you'll see a vertically squashed image with narrow letterbox (16:9 monitor with dvd player set to 4:3. In this case you can get the correct aspect ratio if you set your tv to one of the 'zoom' settings; normally the next option after 4:3 as you cycle through the options, but you are then throwing away roughly 25% of the available resolution and the image will be a bit softer.)
    In DVDSP you can set the simulator to mimic various set-ups in order to check how the disc will behave before you burn.
    If you just want to create QTs then Nick Holmes advice is the way to go.

  • I'm trying to get the ios 4.2.1 on my second generation iPod . Is there a way to install it directly on my iPod touch because my iTunes on my computer is not working. Please help Apple! I need the update. Just give me a link.

    Im trying to get the ios 4.1.2 on my iPod touch 2nd generation. Can I install it directly on my iPod . My iTunes on my computer isn't working!

    you have to have itunes installed but check out http://support.apple.com/kb/ht4623.

  • I am trying to get space on an external hard drive which has some old time machine back up files that I do not need but can not eliminate, even by going into the time machine, clicking on the backup file to be eliminated and using the drop down eliminate

    I am trying to get space on an external hard drive which has some old time machine back up files that I do not need but can not eliminate, even by going into the time machine, clicking on the backup file to be eliminated and using the drop down menu with the gear box symbol to eliminate

    I cannot find this 300GB "Backup" in the Finder, only in the Storage info when I check "About This Mac".
    You are probably using Time Machine to backup your MacBook Pro, right? Then the additional 300 GB could be local Time Machine snapshots.  Time Machine will write the hourly backups to the free space on your hard disk, if the backup drive is temporarily not connected. You do not see these local backups in the Finder, and MacOS will delete them, when you make a regular backup to Time Machine, or when you need the space for other data.
    See Pondini's page for more explanation:   What are Local Snapshots?   http://pondini.org/TM/FAQ.html
    I have restarted my computer, but the information remains the same. How do I reclaim the use of the 300GB? Why is it showing up as "Backups" when it used to indicate "Photos"? Are my photos safe on the external drive?
    You have tested the library on the external drive, and so your photos are save there.  
    The local TimeMachine snapshot probably now contains a backup of the moved library.  Try, if connecting your Time Machine drive will reduce the size of your local Time Machine snapshots.

  • Trying to get Essbase Client 11.1.2.3 for Linux 32bit, please need help

    Hello,
    I am running a RedHat Enterprise Linux 6.4 64-bit system and have an application that requires the 32-bit Essbase Client 11.1.2.X libraries in order to connect to an Essbase 11.1.2 server instance.
    From reading through the forum posts for the past couple days I have come to an understanding that Oracle Essbase 11.1.2 no longer ships a Linux client as a separate assembly so you have to install the full Essbase server then extract the client files out of that to use..  So I am trying to get the correct bundle of files downloaded to even get the installer to launch properly so I can select a minimal installation including client components, but I can't get the correct zip files, I am getting close, but there is still a few missing, and the instructions I have found seem to refer to 11.1.1.X versions that have changed quite a bit in the 11.1.2.X version.
    Can anyone please help me figure out what I am still missing to get the install running and how to extract the client libraries?
    So far, I have downloaded:
    2073792430 Apr 22 11:43 Apps-11123-linux32.zip
    2440713397 Apr 22 11:46 ClientInstallers-11123.zip
    554953827 Apr 22 11:47 Essbase-11123-linux32.zip
    171726540 Jun 20 09:08 FinancialManagementAnalytics-11123-linux32.zip
    1053291166 Apr 22 11:52 Foundation-11123-linux32-Part1.zip
    1603812256 Apr 22 11:53 Foundation-11123-linux32-Part2.zip
    939688909 Apr 22 11:53 Foundation-11123-linux32-Part4.zip
    1597577101 Apr 22 11:55 Foundation-11123-Part3.zip
    1801831469 Apr 22 12:01 OHS-11123-linux32.zip
    366584941 Apr 22 12:04 RA-11123-linux32.zip
    BUT I still have the following missing assemblies I can't account for:
    EPMINS-01001: One or more preinstallation checks failed. Correct the errors before continuing with the installation. 
    Check assemblies: /home/ntruhan/Downloads/essbase/assemblies/biplus_product_reporting_client... Not exists
    Failed!
    EPMINS-01084: Assembly for linux32 platform is used
    Failed!
    EPMINS-01084: Assembly for linux32 platform is used
    Failed! EPMINS-01084: Assembly for linux32 platform is used
    Failed! EPMINS-01084: Assembly for linux32 platform is used
    Failed! EPMINS-01084: Assembly for linux32 platform is used
    /home/ntruhan/Downloads/essbase/assemblies/hfm_services... Not exists
    /home/ntruhan/Downloads/essbase/assemblies/dbclient64... Not exists
    Failed!
    EPMINS-01084: Assembly for linux32 platform is used
    Failed!
    EPMINS-01084: Assembly for linux32 platform is used
    /home/ntruhan/Downloads/essbase/assemblies/hsf_server... Not exists
    /home/ntruhan/Downloads/essbase/assemblies/dbclient32... Not exists
    /home/ntruhan/Downloads/essbase/assemblies/fdm... Not exists
    Failed!
    EPMINS-01084: Assembly for linux32 platform is used
    Failed!
    EPMINS-01084: Assembly for linux32 platform is used
    /home/ntruhan/Downloads/essbase/assemblies/bpm_architect_services... Not exists
    /home/ntruhan/Downloads/essbase/assemblies/hsf_webapp... Not exists
    I am going through the list of entries, but the only references I have seen so far have been for Windows downloads and this is linux, and then there are the Assembly for linux32 messages, but I need that since I need the 32bit client libraries, right?
    Can someone shed some light on this adventure in installing all of this since all of the install instructions I have been seeing are for an older version packaged differently?
    Thank you in advance,
    Nathan

    Thank you for this.  It set me on the right path.  I wound up installing all of them as I was still getting those errors, but after I realized the REAL error was not the aseemblies not exsisting, but it was the "EPMINS-01084: Assembly for linux32 platform is used Failed!"  error.
    The Linux System i was TRYING to install on is RHEL 64bit, but I was trying to install a 32bit client as i needed a 32bit client.  It just refused to install a 32bit client on a 64bit Linux machine.
    I configured a CentOS 32bit Linux VMWare image and viola, the same driver files installed without an error.
    Not sure why the 32bit client would not let me install on a 64bit system, but I finally got it now.
    Now to tar the Essbase directories up and move them over to the RedHat machine where I need them.
    Thank you for your help.

  • I have adobe editions 4.0 and I've been trying to get library books on my kobo for over 2 hours! The book goes onto my Kobo fine, but when I try to open in on my kobo it says, "Oops! The document couldn't be opened. It's protected by ADRM and is not curre

    I have adobe editions 4.0 and I've been trying to get library books on my kobo for over 2 hours! The book goes onto my Kobo fine, but when I try to open in on my kobo it says, "Oops! The document couldn't be opened. It's protected by ADRM and is not currently authorized for use with your Adobe ID." It does it with every single book. I've never had this problem before. I've tried everything! Please help.

    same problem for me. I am using abe edition 3 as I don't think 4 can be used with kobo. Book has been downloaded to kobo but it can't be read as it is not authorised.Help please

  • Trying to get cd onto ipod touch but snching options are greyed out - I've opted to manually manage.

    I'm trying to get CD onto ipod touch. copied it into ITunes library but when I get to synching 'selected playlists etc' all options are greyed out.  If I try and clink sync in bottom right hand corner it gives me warning msg that everything already on ipod will be deleted and I don't want that.  any ideas?

    Head to Settings -> General -> Restrictions on your iPod Touch and make sure that restrictions for app installations are turned off.
    B-rock

  • Latest update of Muse is not installing on several tries,installation gets stuck at 43% and shows '' waiting'' at the  ''Extracting''  stage for 7-8 hours after which it does not progress

    latest update of Muse is not installing on several tries,installation gets stuck at 43% and shows '' waiting'' at the  ''Extracting''  stage for 7-8 hours after which it does not progress.

    Refer to EX11....
    Creative Cloud Error Codes (WIP) | Mylenium's Error Code Database
    Mylenium

  • HT1473 Had to "repair" Itunes today after error messages would not let me open. I can no longer sync my phone to computer without deleting all of the contect on my phone. I don't want to do that! I am trying to get the music from my Iphone to my Itunes li

    Little background:
    Went to open Itunes, error message told me I was missing files and I was unable to open. I deleted Itunes and re-downloaded and received same message. I then "repaired" Itunes from my "unistall/change" program menu. The error message then changed to being "unable to read my library of music." So I fixed that by following some other forum directions (Went to My Computer/Music/Itunes then dragged the most recent Itunes Library selection to my desktop, then opened the folder under music titled "Previous Itunes library" and moved that file into that folder. Thankfully that worked... sort of... I have some music in my library. None of the music from my super old Limewire library, or any recent music from my phone. All of which was in my library last night. Not to mention the HOURS of cd's I burned to Itunes over the entire weekend. Hundreds (at least) of songs are missing.
    So I attempted to sync my phone and was told it would delete all of the files in my phone to replace with files from my computer. Which is NOT what I want to happen. Trying to get music FROM my phone to my computer.
    Can someone please help me simply sync my phone to my computer? And then somehow get the music from my Limewire library to my Itunes library? I know I may not get the burned music back... But that sure would be amazing.
    I am at a loss. Apple won't help unless I pay them... So hopefully this looks familiar to someone!
    Thanks,
    Katie

    This happens if the file is no longer where iTunes expects to find it. Possible causes are that you or some third party tool has moved, renamed or deleted the file, or that the drive it lives on has had a change of drive letter. It is also possible that iTunes has changed from expecting the files to be in the pre-iTunes 9 layout to post-iTunes 9 layout,or vice-versa, and so is looking in slightly the wrong place.
    Select a track with an exclamation mark, use Ctrl-I to get info, then cancel when asked to try to locate the track. Look on the summary tab for the location that iTunes thinks the file should be. Now take a look around your hard drive(s). Hopefully you can locate the track in question. If a section of your library has simply been moved, or a drive letter has changed, it should be possible to reverse the actions.
    Alternatively, as long as you can find a location holding the missing files, then you should be able to use my FindTracks script to reconnect them to iTunes .
    tt2

  • I'm trying to get my itunes media from two different PCs onto my iPhone

    After purchasing media from iTunes (same iTunes account) on two different computers (1x Win Vista desktop and 1x Win XP laptop), is there a way to get all of this media onto my iPhone (3GS)? I was very dissapointed to see that you can only sync one computer at a time which surprised me because usually Apple products are a lot more user friendly and from my humble experience, I have generally found Apple products to just make since although this problem is seriously aggravating. I am trying to get all of the media that I bought on my laptop (Win XP) to sync with my iPhone (3GS) but since I have already been syncing with my desktop (Win Vista), it wants to erase everything that I already had on my phone, including invaluable photos that I have taken of my children and media that I have purchased on the phone itself. This process has already deleted all of the music that I purchased on my phone (I am assuming that I can't get this music back or at least the music that wasn't backed up yet to my desktop). Is there anyway to get all of my media onto this phone and keep the media that is on my phone already or should I just go back to using my HTC Tilt since it has proven to be a lot more user friendly? One would think that Apple would appreciate you purchasing media from iTunes anywhere that you could but it seems that Apple penalizes you for purchasing from iTunes from more than one computer. I have tried to access my iPhone through the "my computer" folder on my Win XP laptop but my iPhone does not show up in this folder (although it does show up in my Vista desktop "my computer" folder). Can anyone please point me in the right direction to find a solution as this problem has been extremely frustrating. I would very much appreciate all the help that anyone could give.

    Will iTunes allow me to do this? I'm not really all that familiar with Windows computers. I have recently had to move to a PC because my $3000 macBook Pro died one month after the warranty was up. How could I get iTunes to accept media from another computer?

  • I'm trying to get organized and I just added a bunch of books and pdfs to my itunes library. They were all added immediately to my ipad and iphone even though, itunes automatically putting books on my idevices

    I'm trying to get organized and I just added a bunch of books and pdfs to my itunes library. They were all added immediately to my ipad and iphone even though I did not want this. I added them to itunes using add to library and I have both devices set to sync only selected books.
    How do I do this in the future so this doesnt happen? Its a lot of work to now manually erase them from each device and it sent my phone over capacity.
    thanks

    I dont see the difference in the posts. I dont think theres anything inaccurate or misleading about what I wrote. The items were immediately added to my ipad and my iphone, even though I have them both set to sync only select items. As soon as I added new titles to my itunes library, they were immediately added to the devices. Not on the next sync. Immediately. Both devices were plugged into the computer at the time. Sorry if I failed to mention they were plugged in but I dont see the signifigance youre making out of it. The problem persists anyway.
    Now that I did a test without the devices plugged in, the new items were still added as soon as I plugged my devices into the computer ( I do not have them set to sync over wifi).
    Since I have both devices set to manually select items to sync, of course I want to manually select new items to sync. For instance, I am not going to read any of these magazines or books on my phone, ever, and I dont want to waste valuable space with them.
    So I'm trying your advice:
    I just tried deselecting sync books. It erased all content from ibooks on my device. I then dragged
    one title onto the device, and it just goes back to syncing select books, with the one title selected.
    It appears that wont work to solve my issue. The next time I add something to itunes it will be put on my phone. Is this really something most people want? To select to manualy control what content is synced, but then have things automatically added. It seems inconsistent to me.

  • I am trying to get minecraft for my iPod touch. When I put in my apple ID it says that I have to verify that I can buy it. I click ok I pulls up a site ask me for my apple ID and then I put in my security questions. After that it ask me some weird questio

    I am trying to get minecraft for my iPod touch. When I put in my apple ID it says that I have to verify that I can buy it. I click ok I pulls up a site ask me for my apple ID and then I put in my security questions. After that it ask me some weird question like Who Is your favorite teacher and another question like what is your least favorite car model. I did not set those as my secure questions. So can u please help me

    Forgotten Security Questions/Answers
    You need to contact Apple by:
    1 - Use the Express lane and start here:
    https://expresslane.apple.com
    then click More Products and Services>Apple ID>Other Apple ID Topics>Forgotten Apple ID security questions.
    or
    Apple - Support -form iTunes Store - Contact Us
    2 - Call Apple in your country by getting the number from here:
    http://support.apple.com/kb/HE57
    or           
    Apple ID: Contacting Apple for help with Apple ID account security
    3 - Use your rescue email address if you set one up
    Rescue email address and how to reset Apple ID security questions
    For general  information see:
    Apple ID: All about Apple ID security questions

  • I am trying to get into my Game Center app but every time I tap on the app it opens too a blank white screen. I have tried several times to reset my phone but I get the same result.

    I am trying to get into my Game Center app but every time I tap on the app it opens too a blank white screen. I have tried several times to reset my phone but I get the same result.

    Hello there Sweebs44,
    It sounds like you are tapping the Game Center app to open it, but the screen is blank. I recommend signing out of your account:
    Go to Settings > Game Center, where you can:
    Sign out (tap your Apple ID)
    From: iPhone User Guide
              http://help.apple.com/iphone/7/#/iph6c493cac
    Then close all the running apps:
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    Double-click the Home button.
    Swipe left or right until you have located the app you wish to close.
    Swipe the app up to close it.
    When you have done that restart the phone sign back into your account and try again:
    iOS: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/ht1430
    Thank you for using Apple Support Communities.
    Take care,
    Sterling

  • I have a Power Mac G4 and i am trying to get it to work with my LCD

    I have a Power Mac G4 and i am trying to get it to work with my LCD Monitor/TV. The connection on the computer is DVI and the connection on the Monitor is DVI. The Monitor says in the manual to hook up computers using the DVI connection. When I connect the too the monitor says there is no video input. I tried changing the settings on the monitor from PC mode to DVI mode and nothing. I have also tried changing the display on the computer to a couple of different settings and nothing. Please Help?

    Hi-
    A little more info please.
    What model G4?
    What Graphics card?
    What OS?
    What model/make of monitor?
    G4AGP(450)Sawtooth, 2ghz PowerLogix, 2gbRAM, RaptorSATAATA, ATI Radeon 9800   Mac OS X (10.4.8)   Pioneer DVR-109, 23" ACD, Ratoc USB 2.0, QCam Ultra, Nikon Coolscan

Maybe you are looking for

  • Tech Comm Suite 3.5 trial updated my licensed Acrobat 9.5 to X, what happens 9.5 when trial is over?

    After installing Technical Communications Suite 3.5 trial version, it updated my Acrobat Pro 9.5 to version X. What happens to my licensed version 9.5 when trial expires? How do I get it back?

  • Is there an easy way to "bulk create" AP Templates

    I'm adding a campus to an existing WCS.  Campus has six buildings, each building has up to 9 floors.  Most floors of the buildings are identical, but every now and then we change the SSIDs deployed on a "per floor basis". I'm wondering if there is a

  • Flash MX

    Hi all, Well, I have an issue with the software FLASH MX! Yes I know it dates from 2004, and there's a new version in etc ... But i want to use Only this one ) Anyway, I only want to use flash MX, all goes well, the problem is when I created a clip,

  • Hexidecimal Non-Allowed Characters in a Unicode System

    We have a function module that we've written to replace non-permitted characters with a space in transfer rules.  We see a lot of invisible hexidecimal characters coming in free form text fields.  This work great for English.  However, we have a Unic

  • DIFFERENT FIGURE SHOWN IN FMEM REPORT COMPARED TO GL FOR GL CODE

    Dear gurus,        when i am comparing G/L accounts and FMEM reports that not tallying for particular G/L accounts only,for that i had checked maping with g/l accounts and commitment item and funds management .but i am not getting where it is wrong.