How seek method works actually??

Hi,
i am not able to understand how seek method works in java.
plz make me clear on this method..
seek(pos)
The position in the file where the next read or write operation will occur.
But it operates entirely different in the following code. only when i put the value as 5 , it prints the value of 7890. if i pass anything other than that, it would return some values which were not written.
import java.io.*;
public class TestIPApp {
public static void main(String args[]) throws IOException {
RandomAccessFile file = new RandomAccessFile("c:\\test.txt", "rw");
file.writeBoolean(true);
file.writeInt(123456);
file.writeInt(7890);
file.writeLong(1000000);
file.writeInt(777);
file.writeFloat(.0001f);
file.seek(9);
System.out.println(file.readInt());
file.close();
}when i open the test.txt file, it contains some junk values. how could i see this txt file in readable format?
plz help me

Pannar wrote:
only when i put the value as 5 , it prints the value of 7890.Makes sense to me. You write a boolean, then an int. Boolean values are written [in one byte|http://java.sun.com/javase/6/docs/api/java/io/RandomAccessFile.html#writeBoolean(boolean)], int values are written [in four bytes|http://java.sun.com/javase/6/docs/api/java/io/RandomAccessFile.html#writeInt(int)]. Positioning the file pointer to the fifth byte gets ready to read the next int value.
In your code, however, you move the pointer to the ninth byte, which is the start of what you wrote as a long value. So, this code...System.out.println(file.readInt());...should be this:System.out.println(file.readLong());
Pannar wrote:how could i see this txt file in readable format? Write text rather than data.
~

Similar Messages

  • [svn] 3051: actually, for some reason this cast is changing how this method works so

    Revision: 3051
    Author: [email protected]
    Date: 2008-08-29 19:19:32 -0700 (Fri, 29 Aug 2008)
    Log Message:
    actually, for some reason this cast is changing how this method works so
    I'm backing it out!
    Modified Paths:
    blazeds/trunk/modules/core/src/java/flex/messaging/io/BeanProxy.java

    As I said in your original post, iTunes U is not available to any institution, government or otherwise, in South Korea. If or when Apple will extend iTunes U to your country is something none of us here can say, and Apple will not until such time as they're ready to make an announcement. What Apple's criteria and requirements are for being able to open iTunes U in a given country is unknown; there is no "procedure" that any of us here can state or direct you to that you could initiate. It's totally up to Apple, and if they are working on this, I'm sure they know who in the SK government they would need to work with.
    Sorry, but you will just have to wait and hope that something develops in the future.
    Regards.

  • How onPageLoad() Method works ?

    I'm trying to put that method working but nothing...
    What steps I need to make to put it work ?
    (Yes, I have the OnPageLoadBackingBeanBase.java )

    Hi,
    I am sorry to say that your question is badly asked and doesn't provide enough information. (http://blogs.oracle.com/shay/2007/03/02 just in case you look for ways to improve this). For customizing the page lifecycle see
    http://download-uk.oracle.com/docs/html/B25947_01/bcdcpal005.htm#sthref828
    Frank

  • How does the .accept() method work?

    Hi,
    I have checked the source code of the ServerSocket implementation that comes with the jdk.
    I tought I was going to find some type of loop. However I found nothing like that! so how does the accept method work.
    I mean when we call the .accept() method, the thread in which the socketServer is initialized gets stoped untill a new client connection is recieved! how is this actually managed?
    Regards,
    Sim085

    At a guess, the accept call that Java makes, relies on the OS system call through JNI. accept would then block until a new connection is present if you are using blocking.

  • Please explain how the method CHECK_CHANGED_DATA works?

    Hi experts,
       Can any of you experts please explain how the method <b>CHECK_CHANGED_DATA</b>
    of <b>CL_GUI_ALV_GRID</b> class works ?
    Thanks in advance
    regards,
    Ashwin

    DATA: l_valid TYPE c.
    Data grid1 type ref to cl_gui_alv_grid.
    CALL METHOD grid1->check_changed_data IMPORTING e_valid = l_valid.
    This method checks if any data is changed on the grid if there any editable fields .
    And updates the changed values
    Message was edited by:
            Chandrasekhar Jagarlamudi

  • How does "notify me" actually work in mail app

    Might be a daft question, but how does "notify me" actually work in iPhone email app?
    I get the principal but surely when you get a reply thats already noticed you?
    Could someone advise me how it actually notifies and is it in addition to receiving the reply to the mail?

    I have the columns in place. But I have a few questions -
    1. Iis there some kind of audit trail report on the updates to my record to the table? If so how do I get to see?
    2. Am I expected to create a <entity name>_HISTORY table for this to work? I see some such recommendation  here .

  • HT4914 How does the payment method work for iTunes Match?

    How does the payment method work with iTunes Match. For example, if you have a gift card, does it take it out of that. Or is there tax? What if you cancel your subscription in the middle of the year, does it take the money for that year or not? If someone could answer those questions it would be greatly apreciated. And if anyone has their own questions, feel free to ask. Thank you.

    Hi HLFrank,
    Welcome to Adobe Forum,
    You can opt for monthly payment in a yearly contract or pay at one go for an year.
    Please check the option at http://www.adobe.com/in/products/creativecloud/buying-guide.html
    Regards,
    Rajshree

  • How paint method in TiledLayer work ?

    It's my 1st time in forum. Does anyone has source code of Sprite, TiledLayer class or know how exactly the paint method work? I had used it in some game but not satisfied with it. I want to code my own class but i wonder it has some native or low-level code.
    Sorry for my poor E !!!

    perhaps you want to use a more hardware oriented approach. I can highly recommend you the Slick API. It is built on top of the LWJGL API set, which is a Java binding for OpenGL, OpenAL and provides device support such as joysticks/joypads. Slick turns the 3D part into an easy to use 2D rendering framework.
    [http://slick.cokeandcode.com/|http://slick.cokeandcode.com/]
    Basic example program:
    [http://slick.cokeandcode.com/wiki/doku.php?id=01_-_a_basic_slick_game|http://slick.cokeandcode.com/wiki/doku.php?id=01_-_a_basic_slick_game]

  • How does the substring method work

    hey folks, does anyone know how the substring method works

    Then you want to use String.split using regular expressions:
    split
    public String[] split(String regex)
        Splits this string around matches of the given regular expression.
        This method works as if by invoking the two-argument split method with the
    given expression and a limit argument of zero. Trailing empty strings are
    therefore not included in the resulting array.
        The string "boo:and:foo", for example, yields the following results with these
    expressions:
            Regex      Result
            :      { "boo", "and", "foo" }
            o      { "b", "", ":and:f" }
        Parameters:
            regex - the delimiting regular expression
        Returns:
            the array of strings computed by splitting this string around matches of
    the given regular expression
        Throws:
            PatternSyntaxException - if the regular expression's syntax is invalid
        Since:
            1.4
        See Also:
            Patternhttp://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#split(java.lang.String)
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum
    Have fun,
    JJ 

  • How does the return method work?

    how does the return method work?

    What do you mean by "return method"? Methods return a value (or void, but that's still a "value" of sorts).
    Returning a Value from a Method
    http://java.sun.com/docs/books/tutorial/java/javaOO/methoddecl.html

  • How to Calculate the Actuall work days ....

    Hi Friends,
    how to calculate the Actuall Working days Based on the Joining date for 5day work and 6 days work?
    is there any FM to calculate this?
    Thanks in Advance,
    sudha.

    Hi Sudha,
    In your company , If they are maintaining Time Events then you can get the information of Employee's Presense or Absense from infotype 2011 (Time Events) and Absense from 2001 (Absense)..
    Also Consider Factory Calender for it.. and check out working days..
    Table TEVEN
    Try below FM as well..
    HR_DV_TIMEEVENTS_GET
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    ilesh Nandaniya

  • How  ExecutorCompletionService 's submit (Callable) method works   ..

    How the submit() works?
    My doubt is ..if i submit 5 tasks by calling 5 times the submit method one by one,
    Will the executor call them at a time( i.e. in multiple threads) or done one by one.
    If one by one fashion what one will be order of execution.
    My Code is
    ExecutorService executorService = Executors.newCachedThreadPool();
    CompletionService< Object > completionService = new ExecutorCompletionService< Object >( executorService );
    // submit all the callables
    for ( Callable< Object > callable : callables )
    completionService.submit( callable );
    for ( int i = 0; i < callables.size(); i++ )
    try
    // execute the delete for this control point table
    completionService.take().get();
    catch ( InterruptedException e )
    // ignore interruptions
    catch ( ExecutionException e )
    // log each error but continue processing
    log.error( "Error deleting file data", e );
    exceptions = true;
    My doubt is when it starts execution after submit().. or when calling take().get()...?
    Please help me ..
    thanks,
    Venkat

    How the submit() works?
    My doubt is ..if i submit 5 tasks by calling 5 times
    the submit method one by one,
    Will the executor call them at a time( i.e. in
    multiple threads) or done one by one.Depends on the ExecutorService that the ExecutorCompletionService is using. You are using a thread pool that has multiple threads so your tasks will be executed simultaneously.
    If one by one fashion what one will be order of
    execution.See above.
    >
    My Code is
    ExecutorService executorService =
    Executors.newCachedThreadPool();
    CompletionService< Object > completionService
    = new ExecutorCompletionService< Object >(
    executorService );
    // submit all the callables
    for ( Callable< Object > callable : callables )
    completionService.submit( callable );
    int i = 0; i < callables.size(); i++ )
    try
    // execute the delete for this control point
    table
    completionService.take().get();
    catch ( InterruptedException e )
    // ignore interruptions
    catch ( ExecutionException e )
    // log each error but continue
    processing
    log.error( "Error deleting file data",
    e );
    exceptions = true;
    y doubt is when it starts execution after submit()..Correct
    or when calling take().get()...?No

  • How to get  the actual data in ALV report

    I am doing some upgradation work   in that i am using Submit  & And return and  also i am using some function modules like LIST FROM MEMORY , LIST TO TXT wnd WRITE LIST , it gives output in normal list format , But i need to print in ALV report .
    With the use of set table for 1st display i got the  ALV report   but not with actual data, (some junk value is showing) , So can any 1 suggest me how to get  the  actual data in ALV report, With the use of  Any Function Module or with Coding,
    with regards,

    Hi Saravana
    I am sure you must be getting the values in tables of table parameters from every FM.
    consolidate the values from tables of all FMs in one table and built ALV for that table only.
    I hope this way you can show the actual data in ALV.
    thanks
    Lalit

  • Question about how wireless networks work

    Hello,
    This is more of a general question rather than one that is specific to the airport. I have a network with an Airport Express with wireless n, a Macbook Pro with a wireless n card, and a printer that has a wireless g card. Someone told me that because I have a wireless g device on my network that I will never get wireless n speeds even when using my computer to do things besides printing because the network is only as fast as its slowest device. Based on this, if there is a computer on my network that has a wireless g card then everyone on the network can only get wireless g speeds even if the others have wireless n cards.
    It was always my understanding that I could not get n speeds when using the printer but I thought that if I were using my computer to connect to the internet, download, upload, etc. (things that have nothing to do with printing and don't require the printer) then I should be able to get wireless n speeds.
    I was wondering if someone could explain how wireless networks work. Thanks in advance.

    The simple answer is that having 802.11g (i.e. 54 Mbit/s) clients on an 802.11n network will NOT slow down the 802.11n clients.
    However, 802.11g works only in the 2.4 GHz band, whereas 802.11n also works in the 5 GHz band, which is potentially much faster. So if you require compatibility with g devices on an AirPort Express, it decreases the potential maximum speed of the n devices, because you have to operate in the 2.4 GHz band. But this slowdown occurs whether or not g devices are actually connected to the network.

  • I need information on how Adobe Drive works and how to set it up

    Hey folks,
    believe it or not, but I have been searching a lot on the web already on how to find information how Adobe Drive works and how to set it up.
    Most information that I found is old and seems to be valid only for older versions of Creative suite. Here in the company we use CS5.5 and will switch to CS6 soon.
    I already downloaded Adobe Drive 3 and installed it on my Mac. Unfortunately I don't know what to do next? Do I need Adobe CQ to make it work? Or can I use it with an existing SVN infrastructure, that we have here? Actually I would like to access the SVN via Adobe Bridge. But after the installation of Adobe Drive my Bridge CS5.5 is crashing while starting up, and I didn't find out how to fix this again.
    Actually I just found the manual for Adobe Drive 3 and read it. Seems to be easy in case its working. But it's not in my case, as mentioned above.
    Any idea what could be the problem?

    Thanks,
    in the meantime I managed to re-setup Adobe Drive 3 again. Bridge CS5.1 is still crashing (i have a log-file with a detailed error-report, if somebody knows how to extract information from this.
    At least now I can start Drive as a standalone application.
    So now my main question is how to connect Drive 3 to our subversion infrastructure in the company. Does anybody have information on this?

Maybe you are looking for

  • Error getting return value from function

    Hello I'm getting a error calling a function with ODP.NET from C# Code: OracleCommand oraCom = new OracleCommand("NORMALIZACION.nif",oraCon); oraCom.CommandType = CommandType.StoredProcedure; OracleParameter param1 = new OracleParameter("numnif",Orac

  • Indexing documents storaged in Documentum Content Server

    Hello experts, I've a question about how i can do the next project. My development team wants develop in our SAP ECC 6.0 system an application that allows them work with the documents storaged in our Documentum Content Server, and after they must be

  • Using iPod location services to find my way round new places

    I  like to use location services with map apps (such as OffMaps and MapsWithMe) to help me find my way around new places. I understand that the information  ipod uses for location services,  the positions of various wifi transmitters,  is stored in a

  • Using Muse to edit Dreamweaver files??

    I just started using Muse and must say it is awesome. However, I am wondering if I can take websites that were created with Dreamweaver and edit them with Muse? Thanks,

  • Federated identity and Visual Studio Online - Restricting Access

    Hi, Using federated identity, can I restrict access to Visual Studio Online only from the corporate network, the same way I can with office 365? If so anyone know what claim rules should be used. Going further can I restrict by client certificate? Th