Saving Linked List to file

Hello,
I have a simple linked link. How do I save the entire list into a file, and and how to I restore the entire link list back into the program so that I can use it normally again?
I guess Serialization is used?
I don't want to save save all the filds in a file, then "re create" the link list by loops etc.

Since Serialization saves the object in question and all the objects it references, if you make you're liunked list element Serializable and then save the first element, the Serialization process will save the entire list.
To get it back, read an Object from the file, it will be the first element of your list and its next link will point at the next element, etc.
If you have a circular list, this still works since the Serialization process will recognice that your saving the same object a second time and only send a reference.

Similar Messages

  • Saving linked list into oracle

    hi, i want to store a linked list in sql, and it should be like that it should grow itself , if i want to add some elements in future,
    i know i have to use jdbc, but if i can get some kind of example for that , it will be quite easier then.....any idea plzz

    Have tables like this?
    LIST table:
    LIST_ID <PK>
    ...any other fields you wish...
    LIST_ELEMENT table:
    LIST_ID <PK> <FK>
    LIST_INDEX <PK>
    ELEMENT_DATA
    ...

  • Saving a list on a file!!!!!

    Hello, I need to save an entire linked list on files and load it again. I dont know much about files. The node have just one object inside, but that object has several fields like name, last_name. Please help

    This is not an excellent suggestion.
    toString() is not intended to prepare a persistable
    e version of the object. You should instead
    investigate the java.io.Serializable interface, which
    is designed for exactly this situation.so what are you saying. it's supposed to be
    non-persistable?
    what do you mean version of the object?
    toString() is supposed to be a representation
    of the object and the fact that you say it shouldn't
    do something doesn't mean much to me.
    if there is a representation of an object that contains
    pertinant information, and this string can be used
    appropriately in the equals and compareTo methods,
    and this same string can be used to represent the
    object in a file, then what is your beef?

  • Saving to text file from GUI within linked list

    can anyone help me with saving to a text file from a GUI text area and text fields??
    then reading back into the labels and textfields from the text file??
    It's currently just saving in a linked list and creating a new item inside of it. but i have to now make a text file for each item, this is what i currently have
    i need to turn this into something that with save to text file with buffered reader or something, can anyone help???
    public void saveToFile()
            while(listIterator.hasNext())
                item = (Item)listIterator.next();
                saving.save(item);
        }//END SAVETOFILE
        public Object save(Item item)
            if (last == 1)
                itemList.set( listIterator.nextIndex() , item);
            else
                itemList.set(listIterator.previousIndex(), item);
            itemList.set(listIterator.previousIndex(), item);
            listIterator = itemList.listIterator(0);
            return itemList.getFirst();   
        }//END SAVE

    thank you sztyopek, i am still having trouble getting it to save to text file. I have to do it through a client and server so i have a protocol class. in the protocol class i have
    if (o instanceof String)
                        //System.out.println(o);
                        if (o.equals("next"))
                            newo = database.getNextItem();
                           // some how send newo
                        if (o.equals("prev"))
                            newo = database.getPrevItem();
                            //some how send newo
                        if (o.equals("save"))
                            database.saveToFile();
                        if (o.equals("exit"))
                            System.exit(1);
                    }//END IF STRING
             if (o instanceof Item)
               newo = database.save((Item)o);
            return newo;
        }When i save what i have entered in the textfields for each record it doesn't create a textfile. and it still getting retrieved from how i set it up before by going to the database.save((Item)o)...the last if statement above but i can't change that to the saveToFile method that u helped me with it says incompatible types or something.
    this is the method it is going to, i assume i have to get rid of this so i stop getting the information from the list and start getting it from the text file.
    public Object save(Item item)
            if (last == 1)
                itemList.set( listIterator.nextIndex() , item);
            else
                itemList.set(listIterator.previousIndex(), item);
            itemList.set(listIterator.previousIndex(), item);
            listIterator = itemList.listIterator(0);
            return itemList.getFirst();   
        }//END SAVEif this makes any sense can u give me a hand.
    As to rob the guy bagging me........i am doing a bachelor of networking and they make us do java for the first year. this is my last semester and last assignment. it is also the last thing i have to do for the assignment. I am not good at java so that is why i am asking for some help i just want to pass this semester then i am never doing it again.
    thanks.

  • HT1751 After "Restoring iTunes Library Backup" it wont link to the files in the iTunes folder. I've followed the correct procedure, and iTunes lists all my music correctly (but with no artwork), but can't locate any of the files. Using Windows 7. Help ple

    After "Restoring iTunes Library backup" it wont link to the files in the iTunes folder. I've followed the procedure as described, and the iTunes folder is in the correct location. iTunes lists all my music correctly (albeit with no artwork), but can't locate any of the files.
    I've been restoring my iTunes folder from a backup hard drive to a new computer on which I've downloaded the latest iTunes (10.7). If this is a newer version than the one I backed up with could this be the problem? (I had the latest (to my knowledge) iTunes when I backed up the folder about 3 weeks ago, was this version 10.7?)
    Or is the version of iTunes (within recent updates) not an issue when restoring a library?
    Using Windows 7.
    Any help please?

    From the top of the page where the scripts live...
    The general method of use is to download the script to a folder of your choice, e.g. your Desktop, Downloads folder or create a folder at ...\iTunes\Scripts. Select a playlist or highlight some tracks in iTunes and then double-click on the script to execute it. If no specific tracks are selected the script will try to work with all tracks in the current playlist. Some scripts offer a choice of track by track confirmation of changes or fully automatic processing of the selection. Many of the scripts can optionally display a progress bar while running.
    You are strongly advised to backup your entire library, or at the very least the iTunes Library.itl file, before use. Test the behaviour of your chosen script on a small group of files first to make sure it does what you want before applying it to large numbers of files.
    Most builds of Windows will execute *.vbs scripts when you double-click them. If that doesn't happen then you might need to visit the Add/Remove Programs or Programs & Features control panel to enable the Windows Scripting Host. I can track down details if you have issues.
    Backing up and restoring data is an area that is often glossed over. Most people don't try to learn much about it until they've lost something important. (Me too )
    If your iTunes library was in the usual layout then normally copying the whole iTunes folder from the User's Music folder in the old computer to the User's Music folder in the new one will usually work fine. Ideally this is done before iTunes is installed so that there is no empty library to replace, and all settings are picked up from the old library. This post contains more details.
    tt2

  • How to write from a linked list collection to a text file.

    Hi,
    I want to write my data in linked list collection to a text file.
    the following is the code of my linked list. how do i write it
    Iwant the data to be comma separated while writing it to a text file.
    please help.
    class MailList
            public static void main(String args[])
                    LinkedList m1 = new LinkedList();
                    m1.add(new Address("J.W.West", "11 Oak Ave",
                           "Urbana", "IL", "118011"));
                    m1.add(new Address("H.S.sandy", "1 k ve",
                           "Bana", "L", "18011"));
                    m1.add(new Address("K.Satish", "1 104 Clarence Street",
                            "Strathfield", "NSW", "135"));
                    Collections.sort(m1);
                    Iterator itr = m1.iterator();
                    while(itr.hasNext())
                            Object element = itr.next();
                            System.out.println(element + "\n");
    }

    look at the API for FileWriter.
    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • How to see the complete list of files linked to the file deleting?

    When in Dreamweaver, if you click to delete a file, a dialog box opens that tells you how many files ahve links to the files you are deleting. It gives a partial list, ending with <more...>; however, you cannot click the word more. How do you get a complete list?

    Hello ArunavA,
    How r u ?
    I dont think we can see the complete history of the changes recorded for InfoObject, only the last changed by can be identified.
    GOTO -> Overview List
    see at the last these details will be available
    Best Regards....
    Sankar Kumar

  • Help with copying contents of file to link list please

    Hi,
    Below is a snippet of code I am playing with. As you can see I have created a LinkList, I now need to copy the contents of a csv file in to that list. The file is several lines long and I need each line in the list.
    I know how to add to the list manually i.e.,
    list.add("First entry in list");
    Could someone help me out with this please.
    Many thanks.
    (***CODE***)
    private LinkedList list = new LinkedList();
         public LinkTest()
              // ** List content START **
              // Open the file today.csv
              File inFile = new File("C:\\today.csv");
         // Create a file stream, wrapping the file
         FileReader fileReader = new FileReader(inFile);
         // Create a second wrapper,
    BufferedReader bufReader = new BufferedReader(fileReader);
         // Read in the first line...
         String s;
         s = bufReader.readLine();
         list.add(s);
         StringTokenizer st = new StringTokenizer(s);
         while (st.hasMoreTokens())
    System.out.println(st.nextToken());
         // ** List content END **
         

    I looked at your code and I thought, what's the question for, it's already adding lines to the list. And then I looked again and had the same thought. The third time I looked I noticed you didn't code the loop that read all the lines from the file. Silly me, I thought your question had something to do with linked lists.
    Anyway, to answer your real question, which is how do you read all the lines from a text file:while ((s = bufReader.readLine()) != null) {
      // do something with the String s here
      // such as adding it to a linked list
    }

  • How to list the files I saved in //var/mobile/ApplicatiDocuments directory?

    I want to list the JPG files in the directory of /var/mobile/Applications/XXXXXX/Documents. Have any API like [[NSBundle mainBundle] pathsForResourcesOfType:@"JPG" inDirectory:path]; to list the files? Thanks. Kevin.

    I think you can just do something like this:
    NSArray *paths = NSSearchPathForDirectoriesInDomains
    (NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSLog(@"documentsDirectory=%@", documentsDirectory);
    NSArray *docDirContents = [[NSFileManager defaultManager]
    directoryContentsAtPath:documentsDirectory];
    for (NSString *fileName in docDirContents)
    if (![[fileName pathExtension] caseInsensitiveCompare:@"jpg"])
    NSLog(@"fileName=%@", fileName);
    - Ray

  • Document Library saving link instead of the whole file

    Hi,
    I was just playing around with the document library v0.92 for application express. The application stores the whole information of the doc inside the database.
    If I wanted to just save the name of the file and the link of the file in the database, and the actually file is stored in windows file directory, how would i do that?
    Was playing around with the application builder but not quite sure how I can do it.
    thanks in advance.

    Hi,
    the file you want to access must be reachable from the database or from the application server.
    A file stored somewhere on c:\user_directory\... will not be accessible by either of them.
    Regards,
    Daniel

  • Can I import my old link lists into 365 site?

    Hi I would like to import all my hard work from my old 2010 sharepoint site into the new 365 site.
    I exported my links to excel but I cannot see an import option on a link list in 365.
    Surely there must be an easy way to do this that I am missing?
    thanks

    Below are the steps to save List as Template:
    >> Go to the List - List Settings - Click on Save List as Template - Provide Template Name and make sure you check the "With Content" box available on the page. 
    Once the List is successfully saved as template, you will find the template under List Templates gallery. Download that template it should have ".stp" extension. Get that file and upload the file to List Templates gallery of your SharePoint Online Office
    365 site. Then create a new app and there you should find the Template and create a list using that template.
    If you have any questions then let me know.
    Please ensure that you mark a question as Answered once you receive a satisfactory response.

  • Cant get list of files from a folder (even though the folder and files are created with the same app)

    Ok so each character rolled with my app gets saved as an html file in a folder i create on the sdcard called RpgApp
    the code to do this is 
    private async Task saveToHtmlCharacter(string name)
    StorageFolder externalDevices = Windows.Storage.KnownFolders.RemovableDevices;
    StorageFolder sdcard = (await externalDevices.GetFoldersAsync()).FirstOrDefault(); //Windows.Storage.ApplicationData.Current.LocalFolder;
    var dataFolder = await sdcard.CreateFolderAsync("RpgApp",
    CreationCollisionOption.OpenIfExists);
    var file = await dataFolder.CreateFileAsync(name+".html",
    CreationCollisionOption.ReplaceExisting);
    using (StreamWriter writer = new StreamWriter(await file.OpenStreamForWriteAsync()))
    writer.WriteLine("<html><head><title>Character File for " + z.charNameFirst + " " + z.charNameSecond + "</title></head><body>");
    //trimed for the post
    now this as i say works perfectly and i can confirm that the files show up in the "RpgApp"folder
    now the next step is to have the app read the names of each of those html files and create a seperate button for each one named for the filename and with the filename as content (later i will link them up to load the html file they are named for in a webbrowser
    panal)
    here is the code that *should* do that
    private async Task readFiles()
    z.test.Clear();
    StorageFolder externalDevices = Windows.Storage.KnownFolders.RemovableDevices;
    StorageFolder folder = (await externalDevices.GetFolderAsync("RpgApp"));
    IReadOnlyList<StorageFile> fileList = await folder.GetFilesAsync();
    //z.test.Add("dummy");
    foreach (StorageFile file in fileList)
    z.test.Add(file.Name);
    public async void buttonTest()
    await readFiles();
    CoreDispatcher dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
    await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    foreach (string name in z.test)
    Button button1 = new Button();
    button1.Height = 75;
    button1.Content = name;
    button1.Name = name;
    testStackPanal.Children.Add(button1);
    now i say should as what i get is an error of "A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.ni.dll" (2 of them in fact one after another)
    more detailed error is at http://pastebin.com/3hBaZLQ9
    now i went through checking line after line to find the error and line that causes it is:
    StorageFolder folder = (await externalDevices.GetFolderAsync("RpgApp"));
    in the readFiles method
    i checked to make sure the case is right etc and its spot on, that IS the folder name, and remember my app creates that folder and creates the files that are inside that folder (and only files my app creates are in that folder) so it should have access
    im 100% stuck its taken me all day to get the files to save and now i cant get them to list correctly
    I have tested the button creation function with fake list data and that worked fine, as i say the error is when i tell it to look at the folder it created
    all help most greatfully recieved

    this was actually solved for me on another forum thread 
    async Task<bool> continueToReadAllFiles(StorageFolder folder)
    if (folder == null)
    return false;
    if (folder.Name.Equals("RpgApp", StringComparison.CurrentCultureIgnoreCase))
    var files = await folder.GetFilesAsync();
    foreach (var file in files)
    test.Add(file.Name);
    return false;
    var folders = await folder.GetFoldersAsync();
    foreach (var child in folders)
    if (!await continueToReadAllFiles(child))
    return false;
    return true;
    public async void buttonTest()
    test.Clear();
    StorageFolder externalDevices = Windows.Storage.KnownFolders.RemovableDevices;
    var folders = await externalDevices.GetFoldersAsync();
    foreach (var folder in folders)
    if (!await continueToReadAllFiles(folder))
    break;
    //.... commented out
    ...now i say solved this is more a workaround...but it works.
    I would love to know why we cant just scan the RpgApp folder instead of having to scan the whole dc card and disregard all thats not in the RpgApp folder

  • Need help regarding Linked List

    I'm a beginner who just spent ages working on the following code.. but need help on re-implementing the following using a linked list, i.e. no array is allowed for customer records but you still can use arrays for names, address, etc.. Hopefully I've inserted enough comments..
    Help very much appreciated!! Thanks! =]
    import java.util.Scanner;
    import java.io.*;
    public class Bank
    /* Private variables declared so that the data is only accessible to its own
         class, but not to any other class, thus preventing other classes from
         referring to the data directly */
    private static Customer[] customerList = new Customer[30];               
         //Array of 30 objects created for storing information of each customer
    private static int noOfCustomers;                                                       
         //Integer used to store number of customers in customerList
         public static void main(String[] args)
              Scanner sc = new Scanner(System.in);
              menu();
         public static void menu()
              char choice;
              String filename;
              int custId,counter=0;
              double interestRate;
    Scanner sc = new Scanner(System.in);
              do
              //Displaying of Program Menu for user to choose
         System.out.println("ABC Bank Customer Management System Menu");     
         System.out.println("========================================");
         System.out.println("(1) Input Data from File");
         System.out.println("(2) Display Data");
         System.out.println("(3) Output Data to File");
                   System.out.println("(4) Delete Record");
                   System.out.println("(5) Update Record");
         System.out.println("(Q) Quit");
                   System.out.println();
                   System.out.print("Enter your choice: ");
                   String input = sc.next();
                   System.out.println();
                   choice = input.charAt(0);     
              //switch statement used to assign each 'selection' to its 'operation'               
         switch(choice)
         case '1': int noOfRecords;
                                       System.out.print("Enter file name: ");
              sc.nextLine();                                             
              filename = sc.nextLine();
                                       System.out.println();
              noOfRecords = readFile(filename);
    System.out.println(+noOfRecords+" records read.");
              break;
         case '2': displayRecords();
              break;
         case '3': writeFile();
         break;
                        case '4': System.out.print("Enter account ID to be deleted: ");
                                       sc.nextLine();
                                       custId = sc.nextInt();
                                       deleteRecord(custId);
                                       break;
                        case '5': if(counter==0)
              System.out.print("Enter current interest rate for saving account: ");
                                            sc.nextLine();
                                            interestRate = sc.nextDouble();
                                            update(interestRate);
                                            counter++;
                                       else
              System.out.println("Error: Accounts have been updated for the month.");
                                            break;
                   }System.out.println();
         }while(choice!='Q' && choice!='q');
    /* The method readFile() loads the customer list of a Bank from a specified
         text file fileName into customerList to be stored as array of Customer
         objects in customerList in ascending alphabetical order according to the
         customer names */
    public static int readFile(String fileName)
         int custId,i=0;
              String custName,custAddress,custBirthdate,custPhone,custAccType;
              double custBalance,curRate;
              boolean d;
    /* Try block to enclose statements that might throw an exception, followed by
         the catch block to handle the exception */
    try
                   Scanner sc = new Scanner(new File(fileName));
    while(sc.hasNext())          
    /* sc.next() gets rid of "Account", "Id" and "=" */
    sc.next();sc.next();sc.next();
    custId = sc.nextInt();
                        d=checkDuplicate(custId);               
    /* checkDuplicate() is a method created to locate duplicating ids in array */
    if(d==true)
    /* A return value of true indicates duplicating record and the sc.nextLine()
         will get rid of all the following lines to read the next customer's record */
                             sc.nextLine();sc.nextLine();sc.nextLine();
                             sc.nextLine();sc.nextLine();sc.nextLine();
                             continue;     
    /* A return value of false indicates no duplicating record and the following
         lines containing the information of that customer's record is being read
         in */
                        if(d==false)
    /* sc.next() gets rid of "Name" and "=" and name is changed to upper case*/
         sc.next();sc.next();
         custName = sc.nextLine().toUpperCase();
    /* sc.nextLine get rids of the following lines to read the next customer's
         record if length of name is more than 20 characters*/
         if(custName.length()>21)
    System.out.println("Name of custId "+custId+" is more than 20 characters");
                                  System.out.println();
         sc.nextLine();sc.nextLine();sc.nextLine();sc.nextLine();
         continue;
    /* sc.next() gets rid of "Address" and "=" */           
         sc.next();sc.next();
         custAddress = sc.nextLine();
    /* sc.nextLine get rids of the following lines to read the next customer's
         record if length of address is more than 80 characters*/                         
                             if(custAddress.length()>81)
    System.out.println("Address of custId "+custId+" is more than 80 characters");
                                  System.out.println();
         sc.nextLine();sc.nextLine();sc.nextLine();sc.nextLine();
         continue;
    /* sc.next() gets rid of "DOB" and "=" */                              
         sc.next();sc.next();
         custBirthdate = sc.nextLine();
    /* sc.nextLine get rids of the following lines to read the next customer's
         record if length of date of birth is more than 10 characters*/                         
                             if(custBirthdate.length()>11)
    System.out.println("D.O.B of custId "+custId+" is more than 10 characters");
                                  System.out.println();
         sc.nextLine();sc.nextLine();sc.nextLine();sc.nextLine();
         continue;
    /* sc.next() gets rid of "Phone", "Number" and "=" */                              
         sc.next();sc.next();sc.next();
         custPhone = sc.nextLine();
    /* sc.nextLine get rids of the following lines to read the next customer's
         record if length of phone number is more than 8 characters*/                         
                             if(custPhone.length()>9)
    System.out.println("Phone no. of custId "+custId+" is more than 8 characters");
                                  System.out.println();
         sc.nextLine();sc.nextLine();sc.nextLine();sc.nextLine();
         continue;
    /* sc.next() gets rid of "Account", "Balance" and "=" */                              
         sc.next();sc.next();sc.next();
         custBalance = sc.nextDouble();
    /* sc.next() gets rid of "Account", "Type" and "=" */                              
                             sc.next();sc.next();sc.next();
                             custAccType = sc.next();
                             if(custAccType.equals("Saving"))
    customerList[noOfCustomers] = new Account1(custId,custName,custAddress,custBirthdate,custPhone,custBalance,custAccType);
    sc.nextLine();
                                                 noOfCustomers++;
                                                 i++;
    else if(custAccType.equals("Checking"))
    customerList[noOfCustomers] = new Account2(custId,custName,custAddress,custBirthdate,custPhone,custBalance,custAccType);
                                                 sc.nextLine();
                                                 noOfCustomers++;
                                                 i++;
    else if(custAccType.equals("Fixed"))
    sc.next();sc.next();sc.next();sc.next();
                                                 curRate = sc.nextDouble();
                                                 Account3 temp = new Account3(custId,custName,custAddress,custBirthdate,custPhone,custBalance,custAccType,curRate);
                                                 customerList[noOfCustomers]=temp;
                                                 sc.nextLine();
                                                 noOfCustomers++;
                                                 i++;
                             else
                                  System.out.println("Account type not defined.");
         if(noOfCustomers==30)
         System.out.println("The customer list has reached its maximum limit of 30 records!");
         System.out.println();
         return noOfCustomers;
    //Exceptions to be caught
    catch (FileNotFoundException e)
    System.out.println("Error opening file");
    System.exit(0);
    catch (IOException e)
    System.out.println("IO error!");
    System.exit(0);
    /* Bubblesort method used to sort the array in ascending alphabetical order
         according to customer's name */
    bubbleSort(customerList);
              return i;
    /* The method displayRecords() displays the data of the customer records on
         screen */
    public static void displayRecords()
    int k;
    /* Displaying text using the printf() method */
         for(k=0;k<noOfCustomers;k++)
         System.out.printf("Name = %s\n", customerList[k].getName());
         System.out.printf("Account Balance = %.2f\n", customerList[k].getBalance());
         System.out.printf("Account Id = %d\n", customerList[k].getId());
    System.out.printf("Address = %s\n", customerList[k].getAddress());
    System.out.printf("DOB = %s\n", customerList[k].getBirthdate());
    System.out.printf("Phone Number = %s\n", customerList[k].getPhone());
         String type = customerList[k].getAccType();
         System.out.println("Account Type = " +type);
    if(type.equals("Fixed"))
         System.out.println("Fixed daily interest = "+((Account3)customerList[k]).getFixed());
         System.out.println();               
    /* The method writeFile() saves the content from customerList into a
         specified text file. Data is printed on the screen at the same time */
    public static void writeFile()
    /* Try block to enclose statements that might throw an exception, followed by
    the catch block to handle the exception */
    try
    int i;
              int n=0;
    //PrintWriter class used to write contents of studentList to specified file
              FileWriter fwStream = new FileWriter("newCustomers.txt");
              BufferedWriter bwStream = new BufferedWriter(fwStream);
              PrintWriter pwStream = new PrintWriter(bwStream);     
    for(i=0;i<noOfCustomers;i++)
         pwStream.println("Account Id = "+customerList.getId());
              pwStream.println("Name = "+customerList[i].getName());
    pwStream.println("Address = "+customerList[i].getAddress());
    pwStream.println("DOB = "+customerList[i].getBirthdate());
    pwStream.println("Phone Number = "+customerList[i].getPhone());
              pwStream.printf("Account Balance = %.2f\n", customerList[i].getBalance());
              pwStream.println("Account Type = "+customerList[i].getAccType());
                   if(customerList[i].getAccType().equals("Fixed"))
                        pwStream.println("Fixed Daily Interest = "+((Account3)customerList[i]).getFixed());
              pwStream.println();
              n++;
    //Closure of stream
    pwStream.close();
              System.out.println(+n+" records written.");
    catch(IOException e)
    System.out.println("IO error!");     
    System.exit(0);
         //Deletes specified record from list
    public static void deleteRecord(int id)
    int i;
              i=locate(id);
    if(i==200)
    //checking if account to be deleted does not exist
    System.out.println("Error: no account with the id of "+id+" found!");
              //if account exists
    else
                        while(i<noOfCustomers)
                             customerList[i] = customerList[i+1];
                             i++;
                        System.out.println("Account Id: "+id+" has been deleted");
                        --noOfCustomers;
         //Updates the accounts
    public static void update(double interest)
    int i,j,k;
              double custBalance,addition=0;
    for(i=0;i<noOfCustomers;i++)
                        if(customerList[i] instanceof Account1)
                             for(j=0;j<30;j++)
                                  addition=customerList[i].getBalance()*interest;
                                  custBalance=customerList[i].getBalance()+addition;
                                  customerList[i].setBalance(custBalance);
                        else if(customerList[i] instanceof Account2)
                             continue;
                        else if(customerList[i] instanceof Account3)
                             for(j=0;j<30;j++)
    addition=customerList[i].getBalance()*((Account3)customerList[i]).getFixed();
    custBalance=customerList[i].getBalance()+addition;
    customerList[i].setBalance(custBalance);
                        else
                             System.out.println("Account type not defined");
              System.out.println("The updated balances are: \n");
              for(k=0;k<noOfCustomers;k++)
    System.out.printf("Name = %s\n", customerList[k].getName());
    System.out.printf("Account Balance = %.2f\n", customerList[k].getBalance());
    System.out.println();
    /* ================== Additional methods ==================== */     
    /* Bubblesort method to sort the customerList in ascending alphabetical
         order according to customer's name */
    public static void bubbleSort(Customer[] x)
    int pass, index;
    Customer tempValue;      
    for(pass=0; pass<noOfCustomers-1; pass++)          
    for(index=0; index<noOfCustomers-1; index++)
    if(customerList[index].getName().compareToIgnoreCase(customerList[index+1].getName()) > 0)
    tempValue = x[index];
    x[index] = x[index+1];
    x[index+1]= tempValue;
    /* Method used to check for duplicated ids in array */     
         public static boolean checkDuplicate(int id)
              int i;
              for(i=0;i<noOfCustomers;i++)
                   if(id == customerList[i].getId())
    System.out.println("Account Id = "+id+" already exists");
                        System.out.println();
    return true;
              }return false;
    /* Method to seach for account id in array */
         public static int locate(int id)
              int j;
              for(j=0;j<noOfCustomers;j++)
                   if(customerList[j].getId()==id)
                        return j;
              j=200;
              return j;
    import java.util.Scanner;
    public class Customer
    /* The following private variables are declared so that the data is only
         accessible to its own class,but not to any other class, thus preventing
         other classes from referring to the data directly */
         protected int id;               
         protected String name,address,birthdate,phone,accType;                              
         protected double balance;               
    // Null constructor of Customer
         public Customer()
              id = 0;
              name = null;
              address = null;
              birthdate = null;
              phone = null;
              balance = 0;
              accType = null;
    /* The following statements with the keyword this activates the Customer
         (int id, String name String address, String birthdate, String phone, double
         balance) constructor that has six parameters of account id, name, address,
         date of birth, phone number, account balance and assign the values of the
         parameters to the instance variables of the object */     
         public Customer(int id, String name, String address, String birthdate, String phone, double balance, String accType)
    //this is the object reference that stores the receiver object     
              this.id = id;
              this.name = name;                         
              this.address = address;
              this.birthdate = birthdate;
              this.phone = phone;
              this.balance = balance;
              this.accType = accType;
    /* The following get methods getId(), getName(), getAddress(), getBirthdate(),
         getPhone(), getBalance() return the values of the corresponding instance
         properties */     
         public int getId()
              return id;
         public String getName()
              return name;
         public String getAddress()
              return address;
         public String getBirthdate()
              return birthdate;
         public String getPhone()
              return phone;
         public double getBalance()
              return balance;
         public String getAccType()
              return accType;
    /* The following set methods setId(), setName(), setAddress(), setBirthdate(),
         setPhone and setBalance() set the values of the corresponding instance
         properties */
         public void setId (int custId)
              id = custId;
         public void setName(String custName)
              name = custName;
         public void setAddress (String custAddress)
              address = custAddress;
         public void setBirthdate (String custBirthdate)
              birthdate = custBirthdate;
         public void setPhone (String custPhone)
              phone = custPhone;
         public void setBalance (double custBalance)
              balance = custBalance;
         public void setAccType (String custAccType)
              accType = custAccType;
    class Account1 extends Customer
         public Account1(int id, String name, String address, String birthdate, String phone, double balance, String accType)
              super(id,name,address,birthdate,phone,balance,accType);
              this.id = id;
              this.name = name;                         
              this.address = address;
              this.birthdate = birthdate;
              this.phone = phone;
              this.balance = balance;
              this.accType = accType;
    class Account2 extends Customer
         public Account2(int id, String name, String address, String birthdate, String phone, double balance, String accType)
              super(id,name,address,birthdate,phone,balance,accType);
              this.id = id;
              this.name = name;                         
              this.address = address;
              this.birthdate = birthdate;
              this.phone = phone;
              this.balance = balance;
              this.accType = accType;
    class Account3 extends Customer
         protected double fixed=0;
         public Account3(int id, String name, String address, String birthdate, String phone, double balance, String accType, double fixed)
              super(id,name,address,birthdate,phone,balance,accType);
              this.id = id;
              this.name = name;                         
              this.address = address;
              this.birthdate = birthdate;
              this.phone = phone;
              this.balance = balance;
              this.accType = accType;
              this.fixed = fixed;
         public double getFixed()
              return fixed;
    Example of a customers.txt
    Account Id = 123
    Name = Matt Damon
    Address = 465 Ripley Boulevard, Oscar Mansion, Singapore 7666322
    DOB = 10-10-1970
    Phone Number = 790-3233
    Account Balance = 405600.00
    Account Type = Fixed
    Fixed Daily Interest = 0.05
    Account Id = 126
    Name = Ben Affleck
    Address = 200 Hunting Street, Singapore 784563
    DOB = 25-10-1968
    Phone Number = 432-4579
    Account Balance = 530045.00
    Account Type = Saving
    Account Id = 65
    Name = Salma Hayek
    Address = 45 Mexican Boulevard, Hotel California, Singapore 467822
    DOB = 06-04-73
    Phone Number = 790-0000
    Account Balance = 2345.00
    Account Type = Checking
    Account Id = 78
    Name = Phua Chu Kang
    Address = 50 PCK Avenue, Singapore 639798
    DOB = 11-08-64
    Phone Number = 345-6780
    Account Balance = 0.00
    Account Type = Checking
    Account Id = 234
    Name = Zoe Tay
    Address = 100 Blue Eyed St, Singapore 456872
    DOB = 15-02-68
    Phone Number = 456-1234
    Account Balance = 600.00
    Account Type = Saving

    1) When you post code, please use[code] and [/code] tags as described in Formatting tips on the message entry page. It makes it much easier to read.
    2) Don't just post a huge pile of code and ask, "How do I make this work?" Ask a specific question, and post just enough code to demonstrate the problem you're having.
    3) Don't just write a huge pile of code and then test it. Write a tiny piece, test it. Then write the piece that will work with or use the first piece. Test that by itself--without the first piece. Then put the two together and test that. Only move on to the next step after the current step produces the correct results. Continue this process until you have a complete, working program.

  • New computer ff install not listing all file types under tools-options-applications

    New windows installation on another with the same version of ff (10.0.2). Clicking local .pls files in this machine gives option to launch VLC media player but on other computer just text appears.
    The extension appears in the applications tab after clicking tools and options on this computer, but the list is far shorter on the other machine and does not include this extension. Is this rectified by installing a plugin? If so which one?

    The issue isn't that VLC isn't playing the files- it is... but linking to the files saved on my system does not launch VLC from Firefox on the other computer like it does on this one. I've actually been able to add to the applications list. Technically I can run the same apps and associations on both machines except that Firefox isn't handling the ".pls" files at all with the other machine
    I've saved a directory structure with .pls files to different streaming radio stations and the directory is linked to from Firefox on both computers... identical directories and files stored. When I bring up one of the folders in this machine and click on the file, I first get the same dialog as you attached- I launch VLC by selecting "Open with" then clicking OK. The radio station plays. I've set it to change stations when I click within the iframe without having to go to VLC and use the open media feature- it does the trick with a single click from Firefox,
    The other machine when I click the file the iframe in which the directory was displayed shows text information (urls and other arcane digital nonsense) as though the file were a text file. Both machines have similar installations.... I do not want to overload on the other machine- it's my communications backup but I would like this arrangement to work as it does on this computer.
    Again, the biggest hint I see is the absence of the ".pls" file type in the list under the "applications" tab after clicking "Tools"-"Options" in Firefox on the machine in question.
    Can something be done either by transplanting missing files from one machine to the next or from about:config to induce the desirable result from the other machine in Firefox?
    .

  • In trying to update I received this message: Firefox 3.6.3(2).dmg.part could not be saved, because the source file could not be read.

    In trying to download an update I first received: "There were problems checking for, downloading, or installing this update. Firefox could not be updated because: No data was received (please try again)" It also gave a link to download manually. When I tried from the Firefox website I got: /Users/(deleted for privacy)/Desktop/Firefox 3.6.3(2).dmg.part could not be saved, because the source file could not be read.
    Try again later, or contact the server administrator. I tried this 3 times.
    == This happened ==
    Not sure how often
    == Mon around 11 am, central time, May 17, 2010

    I have tried downloading the file several times and get the same message: "No data received." I have no other system problems, I navigate well to other sites, but I'm unable to download this upgrade. Any suggestions?

Maybe you are looking for

  • Nota Fiscal Modelo 11A com numeração  zerada e série em branco

    Prezados, bom dia! Estou em uma implementação de SAP onde o cliente continua emitindo  Nota Fiscal de Serviço  em formulário 1/1A. Quando na J1B3N gero a saída neste processo a Nota Fiscal não está recebendo o NFNUM e nem a série. Ela aparece na J1BN

  • How do I disable printing of my PDF if a text field isn't filled in?

    Hello all I'm currently trying to find a way to make the print button of my pdf not work if say a necessary textfield wasn't filled in? I take it that the standard validation scripts won't work? The very helpful fellow from a thread seemed pretty sur

  • Scanlines with DVI-out

    Hi, Like many others I'm a new switcher and my experience with Mac has been good all along so far - except for this one thing; My external monitor is behaving quite strange since I began using it with OSX (formerly used with Win XP). The problem is t

  • JMS Scenario

    Hi All, I was testing JMS to Flat file scenario, and facing issues with the following error. Do you have any idea about this error. Along with my input file I am passing JMS Message properties, based on the certain properties JMS Message Selector ide

  • Clean Deinstallation of CS4 Design Premium for Windows XP

    Would very much appreciate any pointers or pointers to suggestions for a clean removal of CS4 Design Premium.  Many Thanks. Bob