The file just won't load into array...Please Help!

hi i need some help in loading a binary file into an array so that i can edit the data that was saved from previous run..
i could save the file but after that when i try to load it back to memory...i can't...ie. all the information keyed in were lost...please help
this is the Code for the loading process...
     public static void loadAircraft (ArrayList aircraft) {
          try {
               FileInputStream filein = new FileInputStream(".\\Data\\Aircraft.bin");
               ObjectInputStream objectin = new ObjectInputStream(filein);
               Aircraft craft = (Aircraft) objectin.readObject();
               aircraft.add(craft);
               objectin.close();
               filein.close();
          catch (Exception e) {}
     }the above code won't load anything into memory...is there a way for overcoming this?
inside the Aircraft class there are four different data of which they contain two differen data types.
one of which is String and the other three are in int.
Awaiting for reply...thanks

yes...its some objects of an array that i am trying to load back...
erm...i'll show you the whole code maybe...
//to reference the swing library
import javax.swing.*;
import java.util.*;
import java.io.*;
public class SetupAircraft {
     static ArrayList aircraft;
     public static void init () {
          aircraft = new ArrayList(5);
          loadAircraft(aircraft);
     //opens up another sub group while the user
     //entered 1 as his/her option in the SetupSystem
     //menu
     public static void Setup () {
          //this will create a string that is going to be displayed
          //in the input dialog box
          String menu = "  Please select an option:  \n"
                          +"----------------------------\n"
                          +"1) Add New Aircraft\n"
                          +"2) Edit Existing Aircraft\n"
                          +"3) List Aircraft\n"
                          +"4) Delete Existing Aircraft\n"
                          +"5) Save\n"
                          +"6) Return to Main Menu\n\n"
                          +"   Enter a number between 1-6\n";
          //declare a field named option for selection through menu
          int option = 0;
          //continue the loop until the user inputs the number 6
          do {
               //error handling for the input from the menu
               //if the input is not integer the error is caught and
               //reassigning option to be 0
               try {
                    option = Integer.parseInt(JOptionPane.showInputDialog(null, menu,
                               "Setup Aircraft", JOptionPane.QUESTION_MESSAGE));
               catch (NumberFormatException e) {
                    option = 0;
               //determine which option the user has chosen
               //and enters the respective section
               switch (option) {
                    case 1: add(aircraft);
                              break;
                    case 2: edit(aircraft);
                              break;
                    case 3: list(aircraft);
                              break;
                    case 4: //delete(aircraft);
                              break;
                    case 5: save(aircraft);
                              break;
                    case 6:     return;
                    default: JOptionPane.showMessageDialog(null, "Please enter a number between 1-6",
                               "Alert", JOptionPane.ERROR_MESSAGE);
                               option = 0;
          while (true);
     public static void add (ArrayList aircraft) {
          String type = "";
          int first = 0;
          int business = 0;
          int economy = 0;
          do {
               try {
                    type = JOptionPane.showInputDialog(null,"Enter Aircraft Type", "Prompt for Type",
                    JOptionPane.QUESTION_MESSAGE);
                    try {
                         if(aircraft.contains(type)) {
                              JOptionPane.showMessageDialog(null, type + " already exist!",
                              "Error", JOptionPane.ERROR_MESSAGE);
                              type = "-100";
                    catch (Exception e) {}
                    if (type=="-100");
                    else if (type.length()==0) {
                         JOptionPane.showMessageDialog(null, "Please enter an aircraft type",
                         "Error", JOptionPane.ERROR_MESSAGE);
                    else if (!(type.startsWith("-",3))) {
                         JOptionPane.showMessageDialog(null, "Please enter the aircraft type with XXX-XXX format where X is integer.",
                         "Error", JOptionPane.ERROR_MESSAGE);
                         type = "0";
               //catch the input error that the user has produces.
               catch (Exception e) {
                    return;
          while (!(type.startsWith("-",3)));
          //try to ask the user for the passenger's name and if the name field contains
          //no characters at all repeat the prompt for name field until the user presses
          //Cancel.
          try {
               first = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter First Class Capacity",
               "Prompt for Capacity", JOptionPane.QUESTION_MESSAGE));
          catch (Exception e) {
               String error = "For input string:";
               if (e.getMessage() == "null") {
                    return;
               else if (e.getMessage().startsWith(error)) {
                    JOptionPane.showMessageDialog(null, "Please enter only numbers",
                    "Error", JOptionPane.ERROR_MESSAGE);
          try {
               business = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Business Class Capacity",
               "Prompt for Capacity", JOptionPane.QUESTION_MESSAGE));
          catch (Exception e) {
               String error = "For input string:";
               if (e.getMessage() == "null") {
                    return;
               else if (e.getMessage().startsWith(error)) {
                    JOptionPane.showMessageDialog(null, "Please enter only numbers",
                    "Error", JOptionPane.ERROR_MESSAGE);
          try {
               economy = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Economy Class Capacity",
               "Prompt for Capacity", JOptionPane.QUESTION_MESSAGE));
          catch (Exception e) {
               String error = "For input string:";
               if (e.getMessage() == "null") {
                    return;
               else if (e.getMessage().startsWith(error)) {
                    JOptionPane.showMessageDialog(null, "Please enter only numbers",
                    "Error", JOptionPane.ERROR_MESSAGE);
          Aircraft newAircraft = new Aircraft (type, first, business, economy);
          aircraft.add(newAircraft);
          JOptionPane.showMessageDialog(null, "Aircraft Sucessfully Added",
          "Successful", JOptionPane.INFORMATION_MESSAGE);
     public static void edit (ArrayList aircraft) {
          String type = "";
          int first = 0;
          int business = 0;
          int economy = 0;
          do {
               try {
                    type = JOptionPane.showInputDialog(null, "Enter Aircraft Type to Edit",
                    "Prompt for Type", JOptionPane.QUESTION_MESSAGE);
                    if (type.length()==0) {
                         JOptionPane.showMessageDialog(null,"Please enter an aircraft type",
                         "Error",JOptionPane.ERROR_MESSAGE);
                    else if (!(type.startsWith("-",3))) {
                         JOptionPane.showMessageDialog(null, "Please enter the aircraft type with XXX-XXX format where X is integer.",
                         "Error", JOptionPane.ERROR_MESSAGE);
                         type = "0";
               catch (Exception e) {
                    return;
          while (!(type.startsWith("-",3)));
          try {
               int edited = aircraft.indexOf(new UniqueAircraft(type));
               Aircraft craft = (Aircraft)aircraft.get(edited);
               try {
                    first = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter First Class Capacity",
                    "Prompt for Capacity", JOptionPane.QUESTION_MESSAGE));
               catch (Exception e) {
                    String error = "For input string:";
                    if (e.getMessage() == "null") {
                         return;
                    else if (e.getMessage().startsWith(error)) {
                         JOptionPane.showMessageDialog(null, "Please enter only numbers",
                         "Error", JOptionPane.ERROR_MESSAGE);
               try {
                    business = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Business Class Capacity",
                    "Prompt for Capacity", JOptionPane.QUESTION_MESSAGE));
               catch (Exception e) {
                    String error = "For input string:";
                    if (e.getMessage() == "null") {
                         return;
                    else if (e.getMessage().startsWith(error)) {
                         JOptionPane.showMessageDialog(null, "Please enter only numbers",
                         "Error", JOptionPane.ERROR_MESSAGE);
               try {
                    economy = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter Economy Class Capacity",
                    "Prompt for Capacity", JOptionPane.QUESTION_MESSAGE));
               catch (Exception e) {
                    String error = "For input string:";
                    if (e.getMessage() == "null") {
                         return;
                    else if (e.getMessage().startsWith(error)) {
                         JOptionPane.showMessageDialog(null, "Please enter only numbers",
                         "Error", JOptionPane.ERROR_MESSAGE);
               Aircraft newAircraft = new Aircraft (type, first, business, economy);
               aircraft.add(newAircraft);
               aircraft.add(newAircraft);
               JOptionPane.showMessageDialog(null, "Successfully edited aircraft\n"+type+" to capacities\n"
               +"First: "+first+"\n"+"Business: "+business+"\n"+"Economy: "+economy,
               "Successful", JOptionPane.INFORMATION_MESSAGE);
          catch (Exception e) {
               JOptionPane.showMessageDialog(null,e.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);
     public static void list (ArrayList aircraft) {
          JOptionPane.showMessageDialog(null, aircraft.size()+" aircraft found", "Found",JOptionPane.INFORMATION_MESSAGE);
          Object[] aircrafts;
          aircrafts = aircraft.toArray();
          for (int i=0;i<aircraft.size();i++) {
               Aircraft a = (Aircraft) aircrafts;
               JOptionPane.showMessageDialog(null, a, "Aircrafts" + (i+1), JOptionPane.INFORMATION_MESSAGE);
     public static void save (ArrayList aircraft) {
          try {
               FileOutputStream fileout = new FileOutputStream(".\\Data\\Aircraft.bin");
               ObjectOutputStream objectout = new ObjectOutputStream(fileout);
               Object[] aircrafts;
               aircrafts = aircraft.toArray();
               objectout.writeObject(aircrafts);
               objectout.close();
               fileout.close();
               JOptionPane.showMessageDialog(null,aircraft.size()+" aircrafts saved", "Sucessful", JOptionPane.INFORMATION_MESSAGE);
          catch (IOException e) {
               JOptionPane.showMessageDialog(null,e.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);
     public static void loadAircraft (ArrayList aircraft) {
          try {
               FileInputStream filein = new FileInputStream(".\\Data\\Aircraft.bin");
               ObjectInputStream objectin = new ObjectInputStream(filein);
               Aircraft craft = null;
               while ((craft=(Aircraft)objectin.readObject())!=null) {
                    aircraft.add(craft);
               objectin.close();
               filein.close();
          catch (Exception e) {
               JOptionPane.showMessageDialog(null,e.toString());
               e.printStackTrace();
i think thats a bit too long..but it would explain what i am trying to save...its linking to the class Aircraft tho...
thanks...i appreciate your help...

Similar Messages

  • Itunes will not connect with the store.  I get no error message.  The store just won't load on the screen.

    Itunes will not connect to the store.  I get no error message, the store just won't load.

    Have you had a look here,
    Can't connect to the iTunes Store
    From here
    http://www.apple.com/support/itunes/troubleshooting/

  • How do I add a playlist to iTunes Match so that it'll appear on my Apple TV?  It was appeared on it before but ever since I added some CDs to the playlist, it won't show anymore.  Please help.

    How do I add a playlist to iTunes Match so that it'll appear on my Apple TV?  It was appeared on it before but ever since I added some CDs to the playlist, it won't show anymore.  Please help.

    When new content is added to a playlist it has to be updated for it to be available across devices. If it's content that isn't matched the playlist is removed from the cloud. Did you make sure to access store - update iTunes Match? It should do it automatically after a few minutes but the odd time I have to force it.
    Other than that may want to try reboot, log out/in. 

  • I am working on big project and in accidentally flatten the file and i saved it as PSD in then I exited Photoshop. the next time when i open the file it is merged on one page. please help!

    I am working on big project and in accidentally flatten the file and i saved it as PSD in then I exited Photoshop. the next time when i open the file it is merged on one page. please help!

    Flattening and merging are very similar. The main difference is merging keeps the transparent areas, whereas flattening removes all transparent areas by giving it a white background. A good example of flattening is a jpg image.
    Since you have closed the file by closing photoshop, that means that the history is now gone, no way of undoing.
    So that leaves you with two choices.
    You can either recreate the whole document.
    Or you can make selections of areas you are keeping and moving them one at a time to new layers. Keep each object on a separate layer. Then redo the area behind those objects.

  • The App Store is not loading.. Please Help

    Since I bought my mac pro back in 2011, I have never used the app store because it never loads.
    Now I really need it because I trying to download the Yosemite. Below is what I get every time I open the app store on my macbook pro.
    Please help fix this.

    Hi ..
    Several things to try.
    Apps such as Little Snitch, Growl, MacKeeper, and anti virus software, can prevent the App Store from loading
    Disable anti virus software if installed
    Check the firewall in System Preferences > Security & Privacy > Firewall > Firewall Options
    Make sure Gatekeeper is enabled
    Open System Preferences > Security & Privacy then select the General tab.
    Make sure either Mac App Store or Mac App Store and identified developers is selected.
    If that area is grayed out, click the padlock icon to proceed.
    OS X: About Gatekeeper

  • Ipod won't load into "My Library," HELP!

    I was using two Ipods. One was loading music into My Library and the other was loading into a file called "Mark's IPOD." I gave the one of the Ipods away - the one that loaded into the library and deleted the songs out of the library. Now I want my remaining Ipod to download into the library when I hook it up to the computer, but it continues to open a separate file: Mark's Ipod.
    I've uninstalled the ipod software and itunes software and reinstalled it, and deleted the files in "My Music," however the problem is still unresolved. Do I need to find a backup file and get rid of that?
    Thanks for your help.

    Hey,
    did you already checked your past purchases? You can try to locate the missing music using the past purchase menu in iTunes Store.
    The missing songs should be visible with the cloud symbol. Just click on the cloud and download the songs.
    If the music isn't displayed here, maybe it is hidden. You can unhide your purchases in your account information. Please select "Store" > "account" and enter your password. Under the subject "iTunes in the Cloud" you should find a menu "hidden purchases" or something. Unhide the music and you should see it on the past purchases like described.

  • My account won't load...PLEASE HELP

    Please help. I have a brother that hacked into my account and reset my password to nothing. My account is the administrative account but i also have one standard account on my pb. Anyways, now when i go to login to admin, it seems as its logging in but all i really get is one of the blue apple display pictures and the cursor. Nothing else appears, not even my normal display picture.
    But when i do log onto the other standard account on my pb, everything appears fine.
    My admin account won't load, is there anything i can do? Is there a way i can retrieve my files on my desktop(admin) from the standard account? I've tried resetting my password using the apple installation cd, but to no avail.
    PLEASE HELP..it would be greatly appreciated. Thanks!

    If you wish to retrieve all of the admin data from the Users folder, you will have to log in as the root user and then change the permissions of all the admin data. Then, you can delete the User from Accounts in System Preferences. After you have obtained the data from the Admin (with another user as the owner of all) and have successfully deleted the admin account, you can create a new admin account and then transfer all of the data back.
    I am not exactly sure why the account does not load, but creating a new one will solve this issue.

  • Session won't load - ERROR MESSAGE- Please help decipher

    For no apparent reason, when I opened my session I got an Adobe ERROR MESSAGE. Then the session won't load and Audition crashes.
    Here is the message:
    (A big Red X appears in the dialog window)
    Audition has encountered an error.
    [\Monk\main\common\PremiereShell\Src\PlayerFactory.cpp-379]
    Can anyone think of a way I can fix this situation and recover my session? Do you think a reinstall of Audition might help? Other sessions open fine. This session was particularly important because I had been working on it for weeks and this was the final finished version. It had been like pulling teeth to get this one done, then when I finally did get it done...this happened. So yuck!! Fortunately I had done a mixdown before the crash, small blessing. But I need the session, of course.
    Thanks for any ideas at all.

    ozworldz wrote:
    Very good.
    right...because the xml is basically a delimited text file. This kind of file would probably rarely ever get corrupted.
    ROFLMAO! Who told you that?
    It'a a FILE, for heavens' sake. And to any computer, all files are essentially the same thing - a string of bytes. What makes a file vulnerable or less vulnerable is how it's handled by whatever program is using it, or to a lesser extent the storage mechanism. And when it comes to .xml files and Adobe, they don't have a particularly good track record with some of them - notably the ones they use for system settings and presets.
    But I have to say that since Adobe thoughtfully gave us the option to save session data as .xml files, I haven't bothered to save them as anything else - simply because as Suite Spot says, you stand some sort of microscopic chance of being able to rescue the data when all else fails. I am fortunate - most of the stuff I do in MV doesn't use a load of tracks and absolutely no effects (live acoustic music editing), but even though the files aren't that complex, I still back them up regularly during processing because, as they regularly get rewritten and updated, they most certainly are vulnerable.

  • Itunes for windows 7 won't load?? Please Help

    I've tried loading iTunes after restarts and re-installations but for some reason it won't load. I've never had this problem before and can't seem to solve it.
    Any help would be much appreciated
    Thanks
    Trickster

    FIXED IT!!!
    None of these suggestions worked for me. I've started fresh by re-installing iTunes and then holding the shift button whilst loading it. This enables you to pick a new library and from this, it works!!
    A bit of a faf because now i have to get all the info off my phone and in to iTunes but at least it opens now!!
    Boom! ha, I came for help from the apple geeks and it turns out I'm the geek!!

  • My ipod nano just won't turn on. Please help!!!

    Ok. So yesterday I was listening to my ipod and everything and I realized it was running out of battery. So, before I went to work I placed it on the charger as usual. Now this morning I get up and decide I'm going to listen to it again and the screen is black and won't turn on. I even hooked it up to my computer and itunes won't recognize it. I placed it back on the charger and nothing. And, I even tried holding the menu button and the center button at the same time. (because that usually works, but, only when the screen showed the apple icon) And nothing has changed. Please please help me! I really hope it's not dead for good. It is older but there are songs on there i don't think i can replace again. Please help!

    Was this a wall charger?  I was told by an employee not to use a car charger to try and charge my 7th gen Nano.  Also, I plugged it into my work computer and it worked for 30 seconds and then went black. For some reason this kills the battery dead.  Computer wouldn't recognize it and it would not turn on UNTIL I took it to the Apple store and they plugged it up, then it worked.  If you can head to the Genius bar and get a quick once over. These 7th gens are very finicky!

  • I cannot rename files in my Adobe reader app. The files are a mess. Can anyone please help?

    The files in my Adobe reader app are saved automatically with random file names and I cannot change the file name. There is no option of rename. I have iPad2 and iOS 4.

    Update iOS and install the new version of Adobe Reader.

  • Import Failure : It says "the files has no audio or video streams" please help me...

    Hello, I have no idea why this is happened? I went open my saved project, and suddenly several files are offline.. I tried to link back the files but Error Message appear on the screen like the picture above.
    I have never changing anything.. it's still the same files since the last time I saved the project.. hope anyone give me some helps, thank you.

    More information needed for someone to help... please click below and provide the requested information
    -Information FAQ http://forums.adobe.com/message/4200840

  • "The file iTunes Library.itl cannot be read" please help!

    i uploaded the new itunes and restarted my computer but now i can't open itunes at all, whenever i try and open it, it says 'The file "iTunes Library.itl" cannot be read because it was created by a newer version of iTunes.' what does this mean and how can i open itunes without losing all my music? please help!

    the ITL file didn't get converted to v8 properly.
    Try these directions
    http://support.apple.com/kb/TS1967

  • I scratched the code off on my itunes gift card, but the security code won't work either. PLEASE HELP!

    so i scratched the code off a little to hard but the security code won't work either.

    Laura...
    Try here >  iTunes Store: Invalid, inactive, or illegible codes

  • I get a grey screen, or the video just won't load on some sites

    http://www2.sportsnet.ca/video/latest/20070820_Georges_St_Pierre_one_on_one
    http://shoutfan.com/2007/07/31/kendall-grove-%E2%80%98road-to-ufc-74%E2%80%B2-video/
    here are two examples of sites which have videos that I can't
    see. It shows a grey screen where the video should be playing in
    the first link, and the second link I can see the start of the
    video, with a white circle loading and that's it.
    I've uninstalled/reinstalled flash player but I still get the
    same thing, does anyone here know what's wrong? I get this result
    in both IE and Firefox.
    thanks in advance

    Have you had a look here,
    Can't connect to the iTunes Store
    From here
    http://www.apple.com/support/itunes/troubleshooting/

Maybe you are looking for

  • CUCILYNC (CUCIMOC) error loading outlook plug-in

    We are deploying cucilync with Outlook 2010, WIN 7, CUCM 7.1.3, OCS R2 When installing the Outlook Add-in we repeatedly see an error indicating Data Execution Prevention is not compatible.  I tried to change my DEP settings to specifically ignore thi

  • Remove blue line in spectral analysis; paintbrush not selectable

    I'm trying to remove a persons talking from a sound file.  His talking shows up in spectral analysis as the color blue.  Is there some way to select and mute it?  The paintbrush is not selectable, tried to do this manually.  Audition clearly identifi

  • Flash and Shockwave Won't Play in Safari 4.0.1

    I recently got a MBP. After doing additional software installation, I now find that I cannot play anything at youtube.com. I made sure I had the latest Flash Player version. It's working in Firefox but not in Safari. When I try to view an article at

  • Use of APO macro function CHAR_VALUES_INPUT

    I am using APO V7. I am using the APO macro function CHAR_VALUES_INPUT to read in a resource name from the interactive user. Is there a way of making sure that the user entered data is left justified? (I am using the entered name in the RESOURCE_VARI

  • SP2-0103: Nothing in SQL buffer to run.

    Hi All, When i execute the script it throws the following error msg. SP2-0103: Nothing in SQL buffer to run. Thanks in advance!