Urgent!! RandomAccessFile help!!! please!!!

hi.
i'm trying to write records (objects) to a RAF. Each record consist of 1 String and 4 int's. And because i have to read some records randommly i'm using RandomAccessFile.
the following code show the structure of a record and the methods used to manipulate the record's data:
import java.io.*;
public class RegistroSalon
     String clave;
     int posicion, capacidad, modulo, edificio;
     public void read (RandomAccessFile archivo) throws IOException
          byte arregloClave[] = new byte[5];
          posicion = archivo.readInt();
          archivo.readFully(arregloClave);
          clave = new String (arregloClave);
          capacidad = archivo.readInt();
          modulo        = archivo.readInt();
          edificio  = archivo.readInt();
     public void write (RandomAccessFile archivo) throws IOException
          byte arregloClave[] = new byte[5];
          if (clave != null)
               arregloClave = clave.getBytes();
          archivo.writeInt(posicion);
          archivo.write(arregloClave);
          archivo.writeInt(capacidad);
          archivo.writeInt(modulo);
          archivo.writeInt(edificio);
     public int size () { return 21; }
}the next class creates a new file (which is in the same path of my *.java) with blank records:
import java.io.*;
public class CrearArchivoSalon
     private RegistroSalon registro;
     RandomAccessFile archivo;
     public CrearArchivoSalon ()
          registro = new RegistroSalon ();
          try
               archivo = new RandomAccessFile ("salon.txt", "rw");
          catch (IOException e)
               System.err.println("Error al abrir el archivo salon.txt " + e.toString());
               System.exit(1);
     public void crear ()
          try
               for (int i = 0; i < 62; i++)
                    archivo.seek(i * registro.size());
                    registro.write(archivo);
          catch (IOException e)
               System.err.println("Error al escribir en el archivo salon.txt " + e.toString());
               System.exit(1);
     public static void main (String args[])
          CrearArchivoSalon salones = new CrearArchivoSalon ();
          salones.crear();
}the next code is a part of my class that writes records to the RAF:
     public void addRecord ()
          int posicion = 0;
          try
               try
                    posicion = (new Integer (campoPos.getText())).intValue();
                    registro.posicion  = posicion;
                    registro.clave        = campoClave.getText();
                    registro.capacidad = (new Integer (campoEst.getText())).intValue();
                    registro.modulo    = (new Integer (campoMod.getText())).intValue();
                    registro.edificio  = (new Integer (campoEdif.getText())).intValue();
                    archivo.seek((long) posicion * registro.size());
                    registro.write(archivo);
               catch (NumberFormatException e) { }
               campoPos.setText("");
               campoClave.setText("");
               campoEst.setText("");
               campoMod.setText("");
               campoEdif.setText("");
          catch (IOException e1)
               System.err.println("Error al escribir en salon.txt " + e1.toString());
               System.exit(1);
     }for last, the next code is part of my class that reads form the RAF:
     public void readRecord ()
          try
               do { registro.read(archivo); }
               while (archivo.getFilePointer() < archivo.length() && registro.posicion == 0);
          catch (IOException e) { masRegistros = false; }
          if (registro.posicion != -1)
               campoPos.setText(String.valueOf(registro.posicion));
               campoClave.setText(registro.clave);
               campoEst.setText(String.valueOf(registro.capacidad));
               campoMod.setText(String.valueOf(registro.modulo));
               campoEdif.setText(String.valueOf(registro.edificio));
     }i have used the same classes in a previuos program, of course, with different record's fields. It worked just fine. But now i do not know why but it returns me different values for the originals. For example, if the written input is:
registro.posicion = 1
registro.clave = 2103
registro.capacidad = 44
registro.modulo = 100
registro.edificio = 2
the output is (when i read the RAF):
registro.posicion = 1
registro.clave = 2103
registro.capacidad = 11264
registro.modulo = 25600
registro.edificio = 512
can anyone suggest why my records are not being correctly read from the file?
regards and thanks in advance.

Sudha!! Thank you for your attention. I guess you have already discovered I ain't an anglospeaker. But I'm going to do my best.
I have 2 files.
In one of them I write/read records which have:
1 String and 6 int's. These kind of record is called RegistroCurso, defined here:
import java.io.*;
public class RegistroCurso
     String clave;
     int posicion, capacidad, modulo, horaInicio, horaFin, edificio;
     public void read (RandomAccessFile archivo) throws IOException
          byte arregloClave[] = new byte[7];
          posicion = archivo.readInt();
          archivo.readFully(arregloClave);
          clave = new String (arregloClave);
          capacidad = archivo.readInt();
          modulo        = archivo.readInt();
          horaInicio= archivo.readInt();
          horaFin   = archivo.readInt();
          edificio  = archivo.readInt();
     public void write (RandomAccessFile archivo) throws IOException
          byte arregloClave[] = new byte[7];
          if (clave != null)
               arregloClave = clave.getBytes();
          archivo.writeInt(posicion);
          archivo.write(arregloClave);
          archivo.writeInt(capacidad);
          archivo.writeInt(modulo);
          archivo.writeInt(horaInicio);
          archivo.writeInt(horaFin);
          archivo.writeInt(edificio);
     public int size () { return 31; }
}Like you can see, the basic difference between the RegistroCurso's records and RegistroSalon's (defined earlier in this page) records are the number of attributes or fields and the value of the method size ().
When I wrote/read to the file of the records type RegistroCurso there was no problem.
But, when I try to read the content of the file that stores records type RegistroSalon don't appear the original values.
Now, my question is: what is happening?
I mean, why it worked for a kind of record and do not work for another kind? The difference between RegistroCurso records and RegistroSalon records is just 10 bytes!!
Thanks, again.
Omar.

Similar Messages

  • Problem with application !!!Urgent need Help please!!!

    Hello i am trying to make a 2d sprite engine. I have a serious problem. When i start the application sometimes the screen is just gray. and no matter how long i leave it it just stays gray however every now and again if i run it works fine. this is realy troubling me i cant understand it.
    I am try to use a double buffering strategry and also am storing images on accelerated memory if someone could please help me this would be a great help

    ...you will have to post some sample code, i really can't make heads and tails of it with the given information...

  • [code]"URGENT DATABASE HELP PLEASE"[/code]

    hi everyone, I need some urgent help in my program.
    Basically, I want to query a database. The problem is, I do not know what relations exist. Does anyone know of a way I can find out the relations that exist and their schemas?
    Anyone who can help me in this query shall be well rewarded.
    Thanks in advance.

    >>>
    so basically, in a nutshell, you guys are sayingI
    am
    screwed??Judging by your posts: yes. Very much so.sarcasm aside, I meant is there no way I can get the
    database schema simply by doing some funky queries
    from Java?As k the DB guys for the ER diagrams and if they still ask you get the dump ask for acces to some oracle tools like Enterprise Manager Console where you culd figure out the structure your self.

  • Hi all, i need urgently your help please. My touch screen on muy Iphone 5  is not working, i dont understand as it has not been damaged at all, i dont know what happened and need urgently somebody helps me please

    Please anyone there can help me what I can do??!! touch screen of my Iphone 5 is not working at all and dont understand as it has not been damage and it is only 2 months and half!! it is not an old iphone and it has not been damaged, has happened right now and cannot turn off the mobile at all. Tried to take out the nano sim as i though it will be turned off but it has not been! i dont know what i can do and i am desesperate!!! thanks All for your help!!

    Removing the SIM has no affect on the power of the phone. It is just the part that facilitates connecting to your carrier. Try holding the sleep/wake and home buttons together until you see the Apple logo on the screen and then release the buttons. The phone should reboot. You may need to hold the buttons together for 15-30 seconds.

  • URGENT IPHOTO HELP PLEASE!! :)

    I am using my imac to make a slideshow for a friends funeral. I have never done this before. I have created it in Iphoto. WHen I was done, I clicked on Export and it puts it into Itunes. Is that the only way to get the slideshow on a dvd? I added the slideshow to a playlist and I am currently burning it to a dvd. The only option is a data dvd and it says it may take up to an hour to burn even though the dvd should only be 12 min long.
    Does anyone know if I am doing this right or if there is a way to burn it from Iphoto? Help would be much appreciated. Thanks

    Export the slideshow from iPhoto, that makes a movie of it.
    Do you want to use this DVD in a domestic DVD player? If so, then the disk will have to be 'authored' to make it the correct form for that. If you have iDVD then that's the app you use. However, iDVD is no longer developed or distributed by Apple. You may be able to get it on an old iLIfe install disk.
    Other options:
    Burn: http://macupdate.com/app/mac/21992/burn
    Toast: http://macupdate.com/app/mac/6351/toast-titanium
    But there are lots of others too. Search on the App Store or MacUpdate

  • Need urgent bookmark help please

    macbook pro with snow leopard: i had a bunch of webpages of macbook and ios5 tips saved in my 'popular' folder but i decided to move all those to a new folder just for them. dragged the last bookmark into the folder and somehow accidentally deleted the whole folder. is there anywhere to find this folder, it's not in the trash. i'm desperate, thanks.

    thank you so much for your help. after sleeping on it i realized i hardly ever used those bookmarks, i had them there 'just in case'. i remembered about half of them so i'm gonna decide if it's worth the trouble to try and restore the rest. either way, the link you provided will be very helpful now and in the future. thanks again.

  • URGENT Z10 HELP please!

    Hi, I have just received my new z10. just plugged it in and all im getting is an icon which is showing a usb and computer and a red / orange flashing light in the top corner.
    What do you think is wrong with this?
    Many thanks
    Paul

    Read this article. KB33480 

  • Urgent iMac help please

    OK,
    Last weekend my girlfriend got a new iMac (20", 2.4GHz) and everything has been running great.
    Today I went to install Bootcamp for her and everything was going well but there was an error with Windows and it would not properly install. Anyway I went back into OSX, removed Bootcamp and re-installed. I repeated this twice. On the third installation attempt I tried to boot back into OSX but the computer hangs on the grey screen. I can eject a CD by holding the mouse down but I am unable to boot off a CD (holding down the 'C' key).
    If anyone has any further suggestions I would be very grateful as I am in the brown and smelly now!

    Holding the option key will evoke the startup manager and let you select which system volume to boot to. If it does not recognize the disk then you might try resetting the P-RAM first then hold the C key. To reset the P-RAM hold down the Option/Apple/p/r keys until you hear the boot chime at least 3 times.
    George

  • How to implement drop down list in WDP Abap....very urgent...please help me

    Hi Gurus,
    I wanted to implement the drop down list button in the WDP Abap interactive form. Once the users clicks on the drop down button, an RFC should be called and display the details under the drop down button. Please give me the logic with code. Its very urgent...please help me. Please note that it is in WDP Abap interactive forms. We are using NW2004S, ECC6.0.

    Hello,
    you have to use ZCI form to use DDLB in WD-ABA. The content of the DDLB has to be present at rendering time, there is no dinamic call when you click the "dropdown".
    The attribut you map to the DDLB has to be an element with a value-set, and the value set has to contain the text / value pairs.
    >> this will be displayed when you click the dropdown.
    Best regards,
    Dezso

  • Urgent help please, I made an file with the size 1024x768, then i made two folios, one for retina 2048x1536 and one for non retina 1024x768, i have alot of video content in it, everything works perfect on my retina ipad, but when i open it on ipad 2 an er

    Urgent help please, I made an file with the size 1024x768, then i made two folios, one for retina 2048x1536 and one for non retina 1024x768, i have alot of video content in it, everything works perfect on my retina ipad, but when i open it on ipad 2 an error appears on the pages with video content?

    its in german:
    der Vorgang könnte nicht abgeschlossen werden.
    something like the process coundnt be completed

  • Please help URGENT : Chinese handwriting doesn't seem to work on Lion OSX. the handwriting trackpad appears but anything i write in Chinese doesn't appear in word, chrome,..... HELP PLEASE

    please help URGENT : Chinese handwriting doesn't seem to work on Lion OSX. the handwriting trackpad appears but anything i write in Chinese doesn't appear in word, chrome,..... HELP PLEASE
    And in system prefs/language and text/input languages, simplified chinese and traditional chinese are ticked as usual with handwriting options on !!!!

    Please search the forum for "chinese" to find the many other earlier posts about your issue, like
    https://discussions.apple.com/message/15746805#15746805

  • I cant use the highlight, underline, or strikethrough function in a specific pdf file. The file isnt locked. I used to highlight texts from that file before the latest update. The problem occurs only with that file. Urgent need. Please help. Thanks!

    i cant use the highlight, underline, or strikethrough function in a specific pdf file. The file isnt locked. I used to highlight texts from that file before the latest update. The problem occurs only with that file. Urgent need. Please help. Thanks!

    Chester31,
    Thank you very much for sharing your file with us!  Now that we are able to reproduce the problem at our end, you may stop sharing the file on Acrobat.com.
    Do you know when this problem (for not being able to add new highlight/strikeout/underline) has started?  Did you update your iOS from 7.x to 8.0 recently?
    We will continue investigating the problem and let you know what we find.
    Thank you again for your help.

  • HELP WITH IPHONE 4S IPHONE URGENT HELP PLEASE?

    IPHONE URGENT HELP PLEASE?
    for the whole day my network has been 'Searching...'
    i have tried airplane mode on and off, turning my phone on and off and network reset and taking sim in and out.
    so i backed up my phone and restored to factory settings as i don't think i did the option of choosing manually select a carrier.
    my network is still 'searching...' and it won't let my wifi to allow me to activate my iphone. i have tried to connect to itunes and it still won;t work.
    i keep getting a message about no activation server.
    this is a new iphone. i got it replaced on saturday.
    PLEASE SOMEONE HELP ME!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Hello,
    If this is a new iPhone then you will have free access, as all iPhones come with it, to Apple support. I would have them take care of an issue like this.
    Hope this helps.
    Regards,
    Jake

  • b font color ='red' Java JDBC and Oracle DB URGENT HELP PLEASE /font /b

    Hello, I am a newbie. I'm very interested in Java in relation to JDBC, Oracle and SAP.I am trying to connect to an Oracle DB and I have problems to display the output on the consule in my application. What am I doing wrong here . Please help me. This is my code: Please Explain
    import java.sql.*;
    import java.sql.DriverManager;
    import java.sql.Connection;
    public class SqlConnection {
         public static void main(String[] args) {
              Class.forName("oracle.jdbc.driver.OracleDriver"); //Loading the Oracle Driver.
              Connection con = DriverManager.getConnection
              ("jdbc:orcle:thin:@34.218.5.3:1521:ruka","data","data"); //making the connection.
              Statement stmt = con.createStatement ();// Sending a query to the database
              ResultSet rs = stmt.executeQuery("SELECT man,jean,test,kok FROM sa_kostl");
              while (rs.next()) {
                   String man = rs.getString("1");
                   String jean = rs.getString("2");
                   String test = rs.getString("3");
                   String kok = rs.getString("4");
                   System.out.println( man, jean, test,kok );//here where my the
                                                 //compiler gives me errors
              stmt.close();
              con.close();
    }

    <b><font color ='red'>Java JDBC and Oracle DB URGENT HELP PLEASE</font></b>Too bad your attempt at getting your subject to have greater attention failed :p

  • I just got the iphone 4s and my text messages are showing as urgent to others,please help me fix this

    i just got the iphone 4s and my text messages are showing as urgent to others,please help me fix this

    As ckuan said, there's no way to mark messages as urgent from the phone. So, either your carrier is doing something and you'll need to contact them or it't something on the other end. Is it just one person who's seeing your texts as urgent? Or everyone?

  • Just bought Elements 13. Input serial number (starting 1057), which is not recognised and the installation stalls here. Urgent help please...

    Just bought Elements 13. Input serial number (starting 1057), which is not recognised and the installation stalls here. Urgent help please...

    Maryrhire910 I am sorry that you are facing difficulty downloading and installing Photoshop Elements 12.  Are you downloading the installation files from Download Photoshop Elements products | 13, 12, 11, 10?  If so what specific error are you receiving?

Maybe you are looking for

  • ICal - Google Cal - Google Tasks - ICal Tasks - Iphone?

    I have two mac computers, one at work and one at home, and an iphone. I also have an gmail account I use daily..so the question is how can I set it up so I can follow my calender iCal at home and work computer and on the iphone and gmail, everything

  • How do i clear the space used by MAIL on my iPhone5 ?

    I am using the iPhone5 16GB and lately am facing free memory space available issues. I checked on the memory used by various apps and found that MAIL is using 5GB alone. Kindly help me in reducing this... Earlier iOS version, I recollect we had an op

  • Unsupported File Format (nokia lumia 520)

    My Nokia Lumia 520 will not post pictures to social networks, transfer them to my computer, set them as my lock screen or even edit them. I purchased the phone only a couple of months ago and it was working perfectly, but then it would just come up w

  • Mac/Unix path differences causing linking problems?

    At our organization, we have a single monster Xserve running Mac OS X 10.6.7 and Aqua Connect where up to 15 users log in concurrently with different UI sessions and work on pages using InDesign CS3 and CS5. Each user mounts the same AFP sharepoints

  • Copy & pasting a Google code

        I am getting ready to copy & paste Google Analytic's tracking code (for a single domain) so that my website can be tracked by Google Analytics.  However, on one of the instruction pages the following is stated:   "Be sure to copy the snippet and