Can someone else try to compile this and see why the program is returning..

Can someone else try to compile this and see why the program is returning "false" when I try to delete the files on exit (at bottom of code)... I have the source code uploaded to the web as well as my 2 text test files inside a zip file(they need to be unzipped so you can try to test the program) and .class file... the program works the way i want it to, but i just can't seem to delete the 3 temporary files i use... why??? why does it return false???
Thanks in advance,
Disco Hristo
http://www.holytrinity-holycross.org/DiscoHristo/Assemble.java
http://www.holytrinity-holycross.org/DiscoHristo/Assemble.class
http://www.holytrinity-holycross.org/DiscoHristo/tests.zip
* Assemble.java 1.0 02/06/22
* @author Disco Hristo
* @version 1.0
import java.io.*;
import java.lang.*;
import java.util.*;
public class Assemble
     public static void main(String args[]) throws IOException
          if (args.length > 0) //     Checks to see if there are any arguments
               printArgumentInfo ();
          else // if no arguments run the program
               getInput ();
               printToFile ();
               deleteFiles ();
     public static void getInput () throws IOException
     //     Gets the input and then send it to 3 files according to Tags
          File head = new File ("head.chris");
PrintStream headStream = new PrintStream (new FileOutputStream (head));
File body = new File ("body.chris");
PrintStream bodyStream = new PrintStream (new FileOutputStream (body));
File foot = new File ("foot.chris");
PrintStream footStream = new PrintStream (new FileOutputStream (foot));
String input; //     String used to store input                
File d = new File(".");
String files[] = d.list();
for (int n=0; n!=files.length; n++)
     if (files[n].endsWith(".txt") == true)
          String fileName = files[n];
          BufferedReader in = new BufferedReader (new FileReader(fileName));
               while (true)
               input = in.readLine();
               if (input != null)
                    input = input.trim();
                    if (input == null) // if no more input                          
                         break;
                    else if ( (input.compareTo("<HEAD>")) == 0) // if start of <HEAD> text
                         do
                              input = in.readLine();
                                   if (input != null)
                                   input = input.trim();
                                   if ( ((input.compareTo("<BODY>")) == 0) ||
                                                  ((input.compareTo("<FOOT>")) == 0) ||
                                                  ((input.compareTo("</BODY>")) == 0) ||
                                                  ((input.compareTo("</FOOT>")) == 0) ||
                                                  ((input.compareTo("<HEAD>")) == 0))
                                                  //checks to see if tags in input are in correct order
                                        System.out.println("Input Is Incorrectly Formatted - Tag Error");
                                        System.out.println("Close your <HEAD> tag before starting another tag.");
                                        System.exit(1); //exit program without printing data                                                   
                                   if ( (input.compareTo("</HEAD>")) != 0) //if not end of tag
                                        headStream.println(input); //print to text file
                         while ( (input.compareTo("</HEAD>")) != 0);
                    else if ( (input.compareTo("<BODY>")) == 0) // if start of <BODY> text
                         do
                              input = in.readLine();
                              if (input != null)
                                   input = input.trim();
                                   if ( ((input.compareTo("<HEAD>")) == 0) ||
                                                  ((input.compareTo("<FOOT>")) == 0) ||
                                                  ((input.compareTo("</HEAD>")) == 0) ||
                                                  ((input.compareTo("</FOOT>")) == 0) ||
                                                  ((input.compareTo("<BODY>")) == 0))
                                                  //checks to see if tags in input are in correct order
                                        System.out.println("Input Is Incorrectly Formatted - Tag Error");
                                        System.out.println("Close your <BODY> tag before starting another tag.");
                                        System.exit(1); //exit program without printing data                                                   
                                   if ( (input.compareTo("</BODY>")) != 0) //if not end of tag
                                        bodyStream.println(input); //print to text file
                         while ( (input.compareTo("</BODY>")) != 0);
                         else if ( (input.compareTo("<FOOT>")) == 0) // if start of <FOOT> text
                              do
                              input = in.readLine();
                              if (input != null)
                                   input = input.trim();
                                   if ( ((input.compareTo("<BODY>")) == 0) ||
                                        ((input.compareTo("<HEAD>")) == 0) ||
                                             ((input.compareTo("</BODY>")) == 0) ||
                                             ((input.compareTo("</HEAD>")) == 0) ||
                                             ((input.compareTo("<FOOT>")) == 0))
                                             //checks to see if tags in input are in correct order
                                        System.out.println("Input Is Incorrectly Formatted - Tag Error");
                                        System.out.println("Close your <FOOT> tag before starting another tag.");
                                        System.exit(1); //exit program without printing data                                                   
                                   if ( (input.compareTo("</FOOT>")) != 0) //if not end of tag
                                             footStream.println(input); //print to text file
                         while ( (input.compareTo("</FOOT>")) != 0);
               else
                    break;
public static void printToFile () throws IOException
// Prints the text from head.txt, body.txt, and foot.txt to the output.log
     File head = new File ("head.chris");
     FileReader headReader = new FileReader(head);
          BufferedReader inHead = new BufferedReader(headReader);
          File body = new File ("body.chris");
          FileReader bodyReader = new FileReader(body);
          BufferedReader inBody = new BufferedReader(bodyReader);
          File foot = new File ("foot.chris");
          FileReader footReader = new FileReader(foot);
          BufferedReader inFoot = new BufferedReader(footReader);
          PrintStream outputStream = new PrintStream (new FileOutputStream (new File("output.log")));
          String output;     //string used to store output
          while (true)
               output = inHead.readLine();
               if (output == null) //if no more text to get from file
               break;
               else
                    outputStream.println(output); // print to output.log
          while (true)
               output = inBody.readLine();
               if (output == null)// if no more text to get from file
               break;
               else
                    outputStream.println(output); // print to output.log
          while (true)
               output = inFoot.readLine();
               if (output == null) //if no more text to get from file
               break;
               else
                    outputStream.println(output); // print to output.log
          //Close up the files
          inHead.close ();
          inBody.close ();
          inFoot.close ();
          outputStream.close ();     
     public static void printArgumentInfo () //     Prints argument info to screen
          System.out.println("");
          System.out.println("Disco Hristo");
          System.out.println("");
          System.out.println("Assemble.class is a small program that");
          System.out.println("takes in as input a body of text and then");
          System.out.println("outputs the text in an order according to");
          System.out.println("the tags that are placed in the input.");
     public static void deleteFiles ()
          File deleteHead = new File ("head.chris");
          File deleteBody = new File ("body.chris");
          File deleteFoot = new File ("foot.chris");
          deleteHead.deleteOnExit();
          deleteBody.deleteOnExit();
          deleteFoot.deleteOnExit();
}

I tired your program, it still gives false for files deleted. I tool the same functions you used in your program and ran it. The files get deleted. Tried this :
<pre>
import java.io.*;
import java.lang.*;
import java.util.*;
public class FileTest {
     public static void main(String args[]) {
          FileTest f = new FileTest();
          try {
               f.createFile();
               f.deleteFile();
          } catch(IOException ioe){
               System.out.println(ioe.getMessage());
     public void createFile() throws IOException {
          System.out.println("In create file method...");
          File test = new File("test1.txt");
          File tst = new File("text2.txt");
          PrintStream testStream = new PrintStream (new FileOutputStream (test));
          PrintStream tstStream = new PrintStream (new FileOutputStream (tst));
          testStream.println("this is a test to delete a file");
          tstStream.println("this is the second file created");
          testStream.close();
          tstStream.close();          
     public void deleteFile() throws IOException {
          File test = new File("test1.txt");
          File tst = new File("text2.txt");
          System.out.println(test.delete());
          System.out.println(tst.delete());
</pre>
Also check the starting and closing braces for your if..else blocks.
-Siva

Similar Messages

  • Quitting iTunes changes my desktop (can someone else try?)

    If I change my desktop picture while iTunes is running then when I quit iTunes my desktop reverts to the picture it had before I started iTunes. Pretty weird. Can someone else try this?
    I noticed this the for the first time after updating to 10.4.3 last night. I can't say for sure if I'd ever done this exact sequence before the update.

    Same problem - except my whole desktop goes back to defauylt - my files and iTunes and applications are under a username1, username 2, username3, etc. each time I logoff and log back on. I tried the username_new and idisk restore and notheing helps. It's like Groundhog Day (the Bill Murray movie) -- I configure my desktop, restore my Dock with my apps, reimport my iTunes library and then logoff and back on and it all 'disappears' and goes back to like it was when I first got it out of the box. I upgraded to 10.4.4.

  • HT5557 Is there a way to purchase itunes books for someone else as a gift (Christmas) and give them the codes without automatically downloading the purchase for me? Or is an itunes giftcard the only way to go?

    Is there a way to purchase itunes books for someone else as a gift (Christmas) and give them the codes or printout receiptwithout automatically downloading the purchase for me? Or is an itunes giftcard the only way to go?

    TV shows will only appear in the cloud if you are in a country where they can be re-downloaded from the store (you can't add them yourself), in which case they will appear in the Purchased tab in the iTunes store app for re-downloading. But they will only appear there if you are in a country where they can be re-downloaded, and then only as long as the TV company leaves them in the store (content providers occasionally remove their items).

  • When I go to my folders in the doc, the fan feature is not there. It stays in grid. I can click list. Once in list (and list only), the fan option returns. However when I click it, it just goes to automatic. My folders just have 3 items or less in them.

    When I go to my folders in the doc, the fan feature is not there. I stays in grid. I can click list. Once in list (and list only), the fan option has returned. However when I click it, it just goes to automatic. My folders just have 3 items in them. How do I correct this? Quick note...when my son logs into his user account, the fan feature pops right up and works fine. Thanks!

    Is the Dock on the bottom or the side? Fan is not an option with it on the side.

  • My safari keeps closing unexpectedly and when it does it tells me that it quite while using the .GameHouseBeachParty.so plugin. I have no idea what this means! Can someone please help me fix this?

    My safari keeps closing unexpectedly and when it does it tells me that it quite while using the .GameHouseBeachParty.so plugin. I have no idea what this means! Can someone please help me fix this?

    You have the Flashback trojan.
    Check out the replies in this thread for what to do;
    https://discussions.apple.com/message/18114958#18114958

  • Can someone please try this and see if this works for them...

    Hi there
    I cannot get the following to work but according to the mainstage manual this should work. Could someone please try this and see if this works:
    a. Create a new concert based on any template. Delete all patches except one (lets call this remaining patch X).
    b. Add a Bass instrument channel strip at the Concert level (by selecting the Concert in the patch list and then hitting the '+' button on the right within the Channel strips and selecting Software Instrument).
    c. Set the Concert level Bass instrument channel strip to play only on the first 2 octaves or so, by setting the Key Range parameters appropriately.
    d. Click on the remaining patch X. You should see that it automatically has your bass instrument as a split on the left hand octaves on the Mainstage keyboard displayed. So everything good so far.
    d. Now save the concert with any name.
    e. Close the concert.
    f. Re-open the same concert again. Click on the patch X. At this point I would expect the Bass instrument to be showing on the lower octaves. This does not happen for me.
    I've spent a couple of days trying to see if I'm doing something wrong, but cannot figure this out. Please please someone let me know the outcome of trying the above. And if I'm doing something wrong to get this to work, kindly let me know.
    thanks
    Ziggy

    Thank you all for your suggestions and taking the time to try this out. I think I've sussed out what the problem is.
    If you create them like Thor mentions that always seems to work. Thor, I don't understand what you mean by hitting the "+" in the channel strip area. Doing this creates an additional channel strip and not a new patch.
    What I was trying to do before was to include all patches in a set as well. So I have my Concert, then a Set, then patches within my Set. If I added a Bass at the concert level, it looks like this was then propagated to all my patches in my set. But when I closed Mainstage and re-opened, the bass wasn't there at the Set or patch level.
    I really think there is a bug with Mainstage, where if you have Sets and patches within sets, any instruments at Concert level do not get inherited by the Set, patches in the set. I've tried this a few times and tried without using Sets. It always seems to work without Sets.
    So the lesson is not to use Sets, if you want to share concert level intruments.
    Once again, thank you guys for trying this out.
    Ziggy

  • I have a mac book pro and have already downloaded adobe flash player. However when i go to watch a video it says "Block Plug In". But my adobe is already up to date. Can someone help me to fix this so i can watch videos?

    I have a mac book pro and have already downloaded adobe flash player. However when i go to watch a video it says "Blocked Plug In". But my adobe is already up to date. Can someone help me to fix this so i can watch videos?

    If you're sure you've installed the latest version of Flash, take each of the following steps that you haven't already tried. After each step, relaunch Safari and test. For a "missing plug-in" error, start with Step 7. Back up all data before making any changes.
    Step 1
    You might have to log out or reboot before a Flash update takes effect.
    Step 2
    In the Safari preference window, select
    Privacy ▹ Remove All Website Data
    Close the window. Then select
     ▹ System Preferences… ▹ Flash Player ▹ Advanced
    and click Delete All. Close the preference pane.
    Step 3
    If you're only having trouble with YouTube videos, log in to YouTube and load this page. You may see a link with the text "Leave the HTML5 Trial." If so, click that link.
    Step 4
    If you get a warning of a "blocked" or "outdated" plug-in, then from the menu bar select
     ▹ System Preferences… ▹ Flash Player ▹ Advanced
    and click Check Now. Quit and relaunch the browser.
    If the warning persists, triple-click anywhere in the line below on this page to select it:
    /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources
    Right-click or control-click the highlighted text and select
    Services ▹ Open
    from the contextual menu.* A folder should open. Inside it, there should be a file named "XProtect.meta.plist". If that file is missing and you know why it's missing, restore it from a backup or copy it from another Mac running the same version of OS X. Otherwise, reinstall OS X.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination command-C. In the Finder, select
    Go ▹ Go to Folder...
    from the menu bar, paste into the box that opens (command-V). You won't see what you pasted because a line break is included. Press return.
    Step 5
    Open this folder as in Step 4:
    /Library/Internet Plug-Ins
    Delete the following item, or anything with a similar name, if present:
    Flash Player (failing).plugin  
    You may be prompted for your login password.
    Step 6
    Re-download and reinstall Flash. Download it from the domain "get.adobe.com". Don't click a link from any other website, including this one, because you can't trust links. They may be an attempt to trick you into installing malware masquerading as Flash. Type the address into the browser window. Never download a Flash update from anywhere else.
    Step 7
    If you get a "missing plug-in" error, select
    Safari ▹ Preferences... ▹ Security
    from the Safari menu bar and check the box marked
    Allow (or Enable) plug-ins
    Then click the button marked
    Manage Website Settings...
    if present and make sure that the website is not blocked for Flash.
    Step 8
    Select
    Safari ▹ Preferences... ▹ Extensions
    from the Safari menu bar. If any extensions are installed, disable them.

  • Can someone please try this:

    Can somebody else tell me if their NEW model 17" does this?
    Just got the new 17". When I put the computer to sleep, not only does the blue sleep light flash on the front latch, but the right side of the screen flashes a dim white as well (at a constant rate, but different pace than the latch light).
    Is this a new "feature" or is something defective here?
    I also noticed that the Apple logo on the back flashes during sleep (most noticeable when the lid is closed). Maybe this IS an inteded feature after all. Sure is annoying though...
    Sorry for the double post.

    Hi, krypttic - I can't believe that what you're describing could possibly be a feature of the new PBs. Your display, and every other Mac display, should be black when the machine is in sleep.
    The logo on the lid (as you must have discovered, having owned two of these machines) glows as a function of the display backlighting. (This is true of iBooks, as well.) It is not intended to throb when the machine is asleep, and surely not when the lid is closed. This suggests that the logo's throbbing while the machine is asleep is a function of the right side of the screen flashing.
    To rule out this being a software issue, do two things:
    - I believe that booting from your Install & Restore disc will allow you to put the machine to sleep from the Apple menu. Try that and see if your screen exhibits the same behavior.
    - Create a new user account with admin priveleges, log in to that account, put the machine to sleep, and see if the display exhibits this behavior.
    Let us know what you turn up.
    Tuttle

  • HT204291 Airplay speaker unavailable.  The speaker "apple tv" is currently being used by someone else.  What does this mean amd how do I fix the issue so I can play my video through apple tv?

    Airplay speaker unavailable.  The speaker "apple tv" is currently being used by someone else.  What does this mean amd how do I fix the issue so I can play my video through apple tv?

    The video orientation is included with the video's EXIF data and the same for photos. It is that state of the art OS your computer is running that doesn't recognize or completely ignores the EXIF orientation data.
    This link applies to photos but whatever Windoze application you are using to view videos should provide the same or similar.
    http://answers.microsoft.com/en-us/windows/forum/windows_7-pictures/windows-phot o-viewer-or-live-photo-gallery-does/a161c8da-c1ce-4347-a92e-724f9e535c15

  • HT3702 I'm trying to open an iTunes account and was asked to provide one of each:credit card details or gift card details.i provided a gift card details and yet I'm being asked to contact the support team!!! Pls can someone help me out on this..thanx. Bre

    I'm trying to open an iTunes account and was asked to provide one of each:credit card details or gift card details.i provided a gift card details and yet I'm being asked to contact the support team!!! Pls can someone help me out on this as I cant enjoy my new iPad 3 without buying apps

    Brenda, the easiest way to contact the support team is thru the iTunes Customer Service website:
    http://www.apple.com/support/itunes/contact/

  • Somehow my iTunes app has been put into the trash.  How can I get this and all of the stuff that was in it back to my Application folder?  I try to drag it out of trash, but it won't work.

    Somehow my iTunes app has been put into the trash.  How can I get this and all of the stuff that was in it back to my Application folder?  I try to drag it out of trash, but it won't work.

    Also, when I do try to drag it out of the Trash to put it back into Applications (on the Finder sidebar), it asks me to authenticate with the administration password.  I enter it, and then a window appears saying that I can't do that because I do not have permission to modify iTunes.  Please help.

  • I have just changed my ISP and they have informed me that i have to change the IP address on my time capsule. Please can someone tell me how todo this? Thanks

    I have just changed my ISP and they have informed me that i have to change the IP address on my time capsule. Please can someone tell me how todo this? Thanks

    This should really be unnecessary but anyway..
    If you mean the internal IP of the TC, the it can be changed by changing the dhcp settings.. which is weird.
    It looks a bit different in the v6 utility but is easy to do..
    See the DHCP beginning address is split into sections.. change the front section from 10.0 to 192.168
    Then update the TC.. then you will need to change everything on the network as the IP will need to change.. I recommend you simply turn everything off and then on again in correct order.. modem.. TC.. clients. 2min gap.

  • My husband and I both have iPhones on the same account. When he did his update yesterday, he chose both his number and my number during set up. Now he is getting my messages, too. Can someone please help me fix this?

    My husband and I both have iPhones on the same account. When he did his update yesterday, he chose both his number and my number during set up. Now he is getting my messages, too. Can someone please help me fix this?

    What do you mean he chose his and your number during setup. Chose them for what? Is you number showing up in the Settings>Messages>"You can be reached by imessage at" section? If it is he needs to remove it.
    Cheers,
    GB

  • If I remove my nano sim card can someone else put thiers in and use the phone

    If I remove my nano sim car can someone else put theirs in and use the phone

    If the SIM card is from the same carrier there shouldn't be a problem using it in the phone.

  • I have created a flyer in mac pages and need to get it to a printer to do a mass gloss printing. can someone advise how to do this.. should i burn the document to a cd or dvd?  Thanks

    I have created a flyer in mac pages and need to get it to a printer to do a mass gloss printing. can someone advise how to do this.. should i and can i burn the document to a cd or dvd to give to the printer?
    Thanks

    Some may need a CD while others may need a DVD or can use either medium.  Why not call your printer, tell them what you've got and ask them what they need to do the job you want done?  That way, you'll be working with what he/she needs to complete the job properly.

Maybe you are looking for

  • Compromised computer with Microsoft IP address 138.91.146.9

    SSH attacks are incredibly common, and usually originate from foreign countries and random compromised systems on the Internet and I don't pay much attention to them. This attack, however, originated from a Microsoft IP address. That means it's a ser

  • How to map XML File input to VO (eventually to update table) upon fileupld

    Reqirement: I am downloading an XML File (basically name-value pair) from user using OAMessageFileUploadBean. I need to take this file and update to an existing record in the table (cs_incidents_all). XML File schema is well-known in advance. Approac

  • Airport is very sssssslllllllllloooooowwwwwwwww!!!!!

    I have a 1ghz/512 eMac that I have an airport extreme card in, and it seems like sometimes my internet connection is extremely slow or un-responsive! It will sometimes work at normal speed, and sometimes it will completely freeze for a few minutes be

  • Plz  tell me motrola support repeated key events.

    Plz tell me about my this ancient problem that if some device support repeated key event than tell me its name and also provide a link to download it. moreover also tell me about this strange content type:- Here i have content type which is strange f

  • How do I skip the sign in?

    I just purchased Photoshop Elements. To use editor it is telling me I have to sign in with an adobe account and register or the program will stop working in 7 days. I paid for the software... as far as I'm concerned my contact with Adobe is over. I h