Results 1 to 6 of 6

Thread: Help for Indexed-sequential file organized in Java

  1. #1
    Join Date
    Apr 2010
    Posts
    84

    Help for Indexed-sequential file organized in Java

    I need urgent help with a project. I want an indexed-sequential file organized implement with linked index. The file should have as many sentences of any, may, from me to define structured or simple type, methods to insert a sentence, to search for and issuing a sentence, changing a sentence and to delete a sets and to output all sentences are to be developed. I want to a class that is defined in the structured data type selected by me as Element type the "file". Error cases are self-defined by intercepting exceptions. Anyone over there having any idea how to tackle it?? Please help me as soon as possible.!!

  2. #2
    Join Date
    Mar 2008
    Posts
    258

    Re: Help for Indexed-sequential file organized in Java

    So, somehow it looks as if you had strong impact After this the only thing off, right? If I've understood all you should create a file containing the records and to have an index number. Then you do your time classes that I file management
    and may eliminate to implement methods, like the following code :
    Code:
    public class File (
        private String path;
        public static int index = 0;
        public File (String path) (
           this.pfad = path;
           // Here you could have the file for read and write
           // I'm concerned with NEM RandomAccessFile   
        )
        public void setSatz (String s) (
            if (!"". equals (s)) (
               Datei.index + +;
               // Here you will add the sentence with the Indexnr.  before
            )  
        )
        public String getSatz (int index) (
            // Here you pass the entire file with ner loop
            // And check when the index is correct, then you give the
            // Set back
           return rate;
        )
        public String getAll () (
           // Again, go through the whole file and the contents  
           // There are a variable dranhängen
           alle_saetze return;
        )
        public String phrase search (String search) (
          // Complete file and go through check. Equals if
          // There is a consensus
         search_result return;
        ) 
        public void delSatz (int index) (
          // Complete run file, index and find out 
          // Delete
       )
     )

  3. #3
    Join Date
    Apr 2010
    Posts
    84

    Re: Help for Indexed-sequential file organized in Java

    well, make himself thought is good (yes I copied that because I understand the main logic..) You have before you just imagine how times I have done java installation and you should do something. I have really tried to do lot of things.. Anyways I would like to Thank You for trying to solve my problem.

  4. #4
    Join Date
    Apr 2008
    Posts
    193

    Re: Help for Indexed-sequential file organized in Java

    I think that you should create your word class, implement the methods getSatz, addSatz, search phrase, delSatz. I am talking with respect to the coding that has been provided by the "Khushal". Then you will also have to create your class contains an administration NEN Array / Vector of type word. Create the necessary fields in the class word, text, index etc. According to me you should get the solution after doing these things.

  5. #5
    Join Date
    Apr 2010
    Posts
    84

    Re: Help for Indexed-sequential file organized in Java

    I once implemented the following..
    Code:
    import java.util.ArrayList; 
    / ** * This class represents the model of an indexed-organized file with linked index dar. 
    * The file contains as many records of any structured to be defined or * simple type. 
    * methods for inserting, searching, issuing, changing, deleting a record and output 
    * all rates are to implemented. 
    * For ease of use was a record with the primitive string data type selected. * * @ author Daniel Pernold * @ version 3.0 * / public class File (/ / instance variables private ArrayList file; private int number; 
    / ** * Constructor for objects of the class file management * / 
    public File () 
    (/ / initialize instance variable file = new ArrayList (); int number = 0;) 
    / ** * method for inserting a sentence in the array * 
    * @ param index the index value of the sentence in the array 
    * @ param set the contents of the corresponding index value * / 
    public void satzPaste (String content) 
    (// In the event that the rate Delete method, the value of the number variables 
    // does not reduce the delete if (datei.size () <number) (System.out.println ("Here is something gone wrong"); System.out.println ("------------- ------------------------");) 
    // If everything works correctly, add the sentence to datei.add else ((number, content); number + +;) 
    / ** * method for outputting a record * 
    * @ param index the index value of the sentence in the array to be output) will * / 
    public void satzType (int index)
    (// If the ArrayList is not empty if (! file . isEmpty ()) 
    (// If we enter an index does not yet exist if (index> = datei.size ()) (System.out.println ("This script is not yet available"); 
    System.out.println ("-------------------------------------");) else (System.out.println (index + ":" + datei.get (index)); System.out.println ("---------------------------- ---------");)) 
    // If the ArrayList is empty else (System.out.println ("The file has set no store"); System.out.println ("---- ---------------------------------");)) / ** * Method to change a record * 
    * @ param index the index value of the sentence in the array to be changed * @ param content the content to Amending the set * / 
    public void satzSize (int index, String content) 
    (// If the ArrayList is not empty if (! datei.isEmpty ( )) (/ / If we enter an index does not yet exist if (index> = datei.size ()) 
    (System.out.println ("This script is not yet available"); System.out.println ("- ------------------------------------");) else (datei.set (index content) , ("The record with the index" + index + "was"); System.out.println ("successfully to the value" + content + System.out.println "changed"); System.out.println ("- ------------------------------------");)) 
    // If the ArrayList is empty else ( System.out.println ("The file has set no store"); System.out.println ("--------------------------- )) 
    / ** * Method to delete a sentence is a sentence deleted * ----------"); shifts the index of following sentences * 
    * @ param index the index value of the sentence in the array to be deleted should */ 
    public void rate Delete (int index) (// If the ArrayList is not empty, delete the sentence and in lower number by one if (! datei.isEmpty ()) 
    (// If you enter an index does not yet exist if (index> = datei.size ()) (System.out.println ("This script is not yet available"); System.out.println ("---------------- ---------------------");) else (datei.remove (index) number - System.out.println ("The record with the index "+ index +" was deleted successfully "); System.out.println ("-------------------------------- -----");)) // If the ArrayList is empty else (System.out.println ("The file has set no store"); System.out.println ("-------- -----------------------------");)) 
    / ** * Method to output all records * / 
    public void alleSaetzeAusgeben () (// If the ArrayList is not empty if (! datei.isEmpty ()) (for (int index = 0; index <datei.size (); index + +) (System.out.println (index + ":" + file . get (index));) System.out.println ("----------------------------------- --");) 
    // If the ArrayList is empty else (System.out.println ("The file has set no store"); System.out.println ("------------ -------------------------");)) / ** * method for the sequential search of a set * / 
    public void rate search (String value) 
    ( // If the ArrayList is not empty if (()) (boolean found = false datei.isEmpty for (int index = 0; index <datei.size (); index + +) (if (datei.get (index). equals (value)) (System.out.println ("Found!") System.out.println (index + ":" + datei.get (index)); System.out.println ("----- --------------------------------"); found = true;)) if (found == false) (System . out.println ("Nothing Found"); System.out.println ("------------------------------- ------");))
     // If the ArrayList is empty else (System.out.println ("The file has set no store"); System.out.println ("------- ------------------------------");)) / ** * Method to delete all records * / 
    public void allClass ( ) (datei.removeAll (file);))
    Please Help, it is supposed to be chained!! :

  6. #6
    Join Date
    Dec 2008
    Posts
    183

    Re: Help for Indexed-sequential file organized in Java

    After looking at your code, I made another one, and I am sure that it will help you.
    Code:
    / * * Created on 11.01.2005 * * / 
    package com.yourname.datei / ** * @ author bello * * / 
    public interface File (public void addSatz (String set) 
    public void write set (int index) public void aendereSatz (int index, String set); 
    .public void deleteSatz (int index) public void printSaetze () 
    public void search set (String set); public void clear ();) 
    / * * Created on 01.11.2005 * * / 
    package com.yourname.datei; import java.util.Iterator; import java.util.NoSuchElementException 
    / ** * @ author bello * * / 
    public class DateiImpl implements File (private ElementWrapper first; private ElementWrapper last; private int count; public DateiImpl () 
    (first = last = null; count = 0;) public void addSatz (String set) 
    (if (count == 0) (first = new ElementWrapper () last = first; count = 1;) else (last. next = new ElementWrapper (); last = last.next; + + count;) last.id = count; last.element = rate; last.next = null;) 
    public void moreSatz (int index, String set) (boolean success = false; Iterator iter = this.iterator () while (iter.hasNext ()) 
    (ElementWrapper ew = (ElementWrapper) iter.next (); if (ew.id == index) (= ew.element rate; success = true;)) 
    if (success) (System.out.println ("Successfully changed");) else (System.out.println ("phrase not found");)) 
    public void clear () 
    (while (first! = null) (ElementWrapper tmp = first; first = first.next; tmp.next = null;) first = last = null; count = 0;) 
    public void deleteSatz (int index) (ElementWrapper before = null; boolean success = false ; Iterator iter = this.iterator () while (iter.hasNext ()) 
    (s = ElementWrapper (ElementWrapper) iter.next (); if (s.id ==) 
    (if (before! = null) (before index . s.next next =, s = null;) else (first = s.next; s = null;) success = true; 
    System.out.println ("phrase deleted with id:" + index);) if (! success) before = s;) if (success) 
    System.out.println ("phrase not found with index" + index);) public void printSaetze () (boolean success = false; Iterator iter = this.iterator (); while (iter.hasNext ()) 
    (ElementWrapper s = (iter.next ElementWrapper) () System.out.println ("record with id:" + s.id + ":" + s.element) success = true ;) 
    if (success) System.out.println ("Nothing found to print");) 
    public void phrase search (String set) (boolean success = false; Iterator iter = this.iterator () while (iter.hasNext ( )) 
    (s = ElementWrapper (ElementWrapper) iter.next (); 
    if (s.element.equals (set)) (System.out.println ("set found:" + (String) s.element) success = true ;)) 
    if (success) System.out.println ("found set" + set);) public void write set (int index) (boolean success = false not; Iterator iter = this.iterator () while (iter. hasNext ()) 
    (s = ElementWrapper (ElementWrapper) iter.next (); 
    if (s.id == index) (System.out.println ("set found:" + (String) s.element) success = true ;)) 
    if (success) System.out.println ("phrase not found with index" + index);) private Iterator iterator () (return new Iterator () (ElementWrapper tmp = first; public boolean hasNext () (return! tmp! = null;) 
    public Object next () (if (tmp == null) (throw new NoSuchElementException ();) Object ret = tmp; tmp.next = tmp; return ret;) 
    public void remove () (throw new UnsupportedOperationException ();))) class ElementWrapper (int id; public Object element; public ElementWrapper next;))
     / * * Created on 11.01.2005 * * / package com.yourname.datei / ** * * @ author bello * / 
    public class TestClass (public static void main (String [] args) (File di = new DateiImpl (); 
    String firstSatz = "first rate" String secondSatz = "second rate" 
    String third set = "third rate"-ie.addSatz (firstSatz); 
    di.addSatz (secondSatz); 
    di.addSatz (third sentence); 
    di.printSaetze (); 
    di.searchSatz (firstSatz); 
    di.searchSatz ("different set"); 
    di.writeSatz (1); 
    di.writeSatz (10); 
    di.deleteSatz (2); 
    di.printSaetze (); 
    System.exit (0);))

Similar Threads

  1. Replies: 4
    Last Post: 19-04-2011, 04:34 AM
  2. Sequential file and Random file in VB ?
    By GOOL in forum Software Development
    Replies: 3
    Last Post: 08-01-2011, 08:52 AM
  3. Indexed Sequential Access Method
    By Davis Alek in forum Software Development
    Replies: 3
    Last Post: 31-08-2009, 12:15 PM
  4. The file is not indexed and cannot be imported
    By NIcaBoy in forum Windows XP Support
    Replies: 2
    Last Post: 24-10-2006, 11:51 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,291,265.73796 seconds with 17 queries