Going to a certain line in a RandomAccessFile?

Hi, this doesn't seem to belong anywhere else, since Java doesn't have a forum on I/O. This is pretty simple, but is there any way to go to a certain line in a RandomAccessFile (such as a text file)? seek() doesn't work, it only starts from the character on a line. Is there a way, or should I be using a different kind of I/O medium?
Frumple

well, i would recommend using a random access file and the seek() method... what are you trying to do? like, are you trying to search through the file?
if youre trying to search somehow, then i would write method thatll use a binary search on the file. but, it wouldnt actually store the file contents in a vector or anything, it would use the file.length() property to get the length, and then divide that in half, etc.... now, when you divide it in half, you wont always get to the first position of the line, so you would have to increment/decrement the seek position, until you reach the end of the line... this sounds difficult and it kinda sounds like itll slow down the program.. but, actually i just wrote a method that does this and its AMAZINGLY fast. extremely fast...
good luck. talk to ya later,
Steven Berardi
---------------------

Similar Messages

  • Tab key goes to IE Address Line

    Using either Captivate 2 or 3 (it was happening in both), my
    problem was with the Tab key going to the Address line in Internet
    Explorer (rather than staying within the module as it should). The
    problem seemed like it was inconsistent, but turns out there was a
    trigger. After much trial and error I discovered that all tab
    interactions that occured before I put in a Question Slide worked
    just fine, but any that occured after the first instance of a
    Question slide started going up to the address line. So, I am
    either going to have to eliminate the question slides, or put them
    at the end. I'm mostly posting this as an FYI to everyone (although
    it may be common knowledge, I don't know...I certainly couldn't
    find any reference to it, and Adobe themselves couldn't give a
    solution), but I also wanted to ask if anyone has had this problem
    and come up with a way to still use question slide s interspersed
    within other slides that use the Tab key for interaction?

    *NOTE: I found this workaround on the web and it worked for
    me
    In all versions of Macromedia's Flash Player prior to version
    7.0.14.0, once typing focus was established (by clicking on the
    Flash movie), pressing the Tab key would move you between fields or
    objects in the movie - maintaining focus in the movie itself. As of
    version 7.0.14.0, the Flash Player switched to a behavior called
    "seamless tabbing". In this version, pressing the Tab key moved the
    focus right out of the movie and on to fields in the web page, the
    browser address bar, etc.
    Needless to say, this has caused some difficulty to authors
    using Flash (or RoboDemo) to create simulations where the learner
    needs to tab. So, as of version 7.0.19.0 of the player, seamless
    tabbing is now an html parameter. Here's the official scoop from
    Adobe's release notes of that version of the player:
    Disabling seamless tabbing
    This release of ActiveX Flash Player supports a new HTML
    parameter called SeamlessTabbing. The default value is true; set
    this parameter to false to disable "seamless tabbing", which allows
    users to use the Tab key to move keyboard focus out of a Flash
    movie and into the surrounding HTML (or the browser, if there is
    nothing focusable in the HTML following the Flash movie). ActiveX
    Flash Player has supported seamless tabbing since version 7.0.14.0.
    Disabling seamless tabbing restores the tabbing behavior of Flash
    Player 6, in which tabbing from the end of the tab order inside a
    Flash movie wraps the focus back to the first focusable object in
    the Flash movie. Here is an example of disabling seamless tabbing:
    <object ... >
    <param name="SeamlessTabbing" value="false">
    </object>
    NOTE: In version 7.0.14.0 there is no way to disable seamless
    tabbing. Meaning that your simulation might just never work with
    this version. Fortunately it only took Adobe one 'sub-release' to
    realize and correct this problem.
    So, if you're encountering this problem you'll want to:
    Publish the project with html checked
    Edit the HTML field for any media types which display Flash
    movies (including flash output from other programs like RoboDemo)
    and
    Add the line
    <param name="SeamlessTabbing" value="false">
    somewhere in between the <object... .../object>
    save the Html File.
    I know this is a lot to take in, but it's really a simple
    fix.

  • How to skip certain lines for a txt file and insert into array

    so here is my question:
    i had a file to read, and it requires to input into the array starting from a certain line
    example:
    4
    john 25 M
    mary 22 F
    lee 20 M
    faye 10 F
    faye john
    mary john
    mary faye
    i want to insert the friend list, starting 5th line into a 2d array, which is the int from first line +1.
    can someone help me with it?
    i believe there is a skip method and stuff..
    but just dont know how to use it
    may someone tell me how to do tat?

    the thing is i think that takes too long and it is not efficient..
    however...i just solved it with a better method
    Scanner in = new Scanner (reader);
    int size = Integer.parseInt(in.next());
    BufferedReader insert = new BufferedReader(new FileReader(new File(input)));
    String line = null;
    int count = 0;
    int startAtLineNo =size+1; // 0-based
    while ((line = insert.readLine()) != null) {
    if (count >= startAtLineNo) {
    /* do stuff */
    System.out.println(line);
    // else ignore
    count++;
    thanks anyways

  • Will an iPhone automatically turn off location services.  If it goes below a certain battery power level, and so how you disable this in settings.

    I am working with Georgia DOT and we have created an app to track our state vehicles using IPhone 5. My question is: will an iPhone automatically turn off location services?  If it goes below a certain battery power level, and if so how do you disable this in settings.
    Message was edited by: mickyel

    I don't believe that this will happen, however, the entire iPhone will shut down when the iPhone reaches the auto-shutdown power level. There is no way to turn that Off other that connecting the iPhone to power.

  • Hiding certain line items in FBL3N

    Hi,
    I need to hide certain line items when viewing through TCode FBL3N.... Can this be done? This is just a temporary thing. Pls let me know whether this can be done?
    Thanks,
    Maleeq

    Hi Maleeq,
    Narrow down your parameters for viewing the report. I mean the more parameters you give, the more specific will be your report.
    You can make use of the Dynamic selections to give more parameters so that you will not see the unwanted line items in your report.
    Regards,
    Mike

  • Tab going to a new line when end of line is reached

    In most text editors, when you hold the tab key down, the cursor goes from tab stop to tab stop across the line. When end of the line is reached, the cursor goes to the next line, again goes from tab stop to tab stop on the new line, and so on. You end up with multiple lines.
    In TLF, with tabStops set, holding the tab key down, the cursor goes from tab stop to tab stop across the line. But when the cursor reaches the end of the line, it doesn't go to the next line. The cursor stays at the end of the line while more tab characters are inserted into the text flow. There is always only one line.
    Is there a way for TLF to have the tab key go to the next line when the cursor reaches the end of the line?
    Thanks for the info.
    Will

    Thank you very much for the update.
    We also discovered that, any line which has the previous line ending in a tab, any leading tabs will not show. For example (all in the same <p>):
    Line one ...<tab/>
    <tab/>Line two
    The leading tab on line two will not display. If the previous line does not end with <tab/>, then the leading tab on the following line shows. Is this related?
    Also, will the fix come in a 2.x update? Any time frame?
    Thanks again for the info.
    Will

  • Sapscript symbol for a certain line containing variable characters

    Hi,
    Can you tell me a symbol in sapscript that tells us the size of a certain line ?
    Meaning that if I choose font Times new roman with size 10 and I have 30 characters, then the symbol can tell me how wide my line of 30 characters is. When I increase the font size to 20pt, obviously the width of the line of 30 chars will change, and the symbol should tell me how wide it is.
    Thank you.

    Thanks for your reply.
    If it is not possible for a symbol, then any solutions are ok. If you know any method that can help me, like function module, BAPI etc...please raise it. Any ideas are welcome.
    If you want to know more details of my issue, so here's the description: I have to wrap the text for a column of a table in a form, but I only can adjust the numbers of characters when they are in upper case, so when they input text in lower case, there will be a space between the text and the rest of the column. If I adjust the character numbers of the wrap-text function due to lower case, then when people input the text in upper case, the text will be overflow the column.
    Therefore the things I need to do are:
    + 1st: capture the column's width in the form, passing it to the program
    + 2nd: capture the paragraph format and character format of the input text
    + 3rd: calculate the length of the input text with those formats
    + 4th: wrap the text due to maximum space that the column can fit.
    Here are my solution, and I'm getting stuck just from the very first step
    rgds,

  • How to "commit" only certain lines of code in the script file?

    Hi there,
    Is there a way to execute only certain lines of code in the script file without executing all the code in it. Wihtout using the comment syntax.
    e.g: there are lines to create views and in the next set of line there are lines to create procedures. I only want to execute the lines that create views.

    another workaround is to create a procedure that accepts parameters. such that the parameter will be the basis for what objects in your conditions that it should met to perform the operations that conform with your business rules. an example is given below.
      create or replace procedure create_object(pObjectType varchar2) as
      begin
        if pObjectType = 'VIEW' then
        elsif pObjectType = 'PROCEDURE' then
        else
        end if;
      end;

  • How can I un-receive an good receipt in SAP, FOR A CERTAIN LINE ITEM

    hi experts,
    can any one please help me to solve this issue.
    "How can I un-receive an good receipt in SAP, FOR A CERTAIN LINE ITEM"
    thanks in advance,
    mohammad.

    Hi,
    In T-code MIGO, you select the line item you want and enter all the details of this line in Item details. Tick Item Ok indicator for this line item.
    Untill and unless you tick the item ok indicator for certain line item you couldnot receive the material.
    If you already received the material then Go to MBST and cancel the material document for the same.
    Hope this will help you.
    Regards,
    Goraksh.
    Edited by: goraksh dhikale on Sep 22, 2008 11:30 AM

  • How to read a file starting from certain line number

    Hi there
    I need to read a large text file line by line. The user will have the ability to stop at any time and run the application to resume reading and processing. For example, if the user stops at line 350, next time when the user run the application, I want him to be able to start with line 351. I am using BufferedReader to read the file. What should I do enable to read the file starting certain line number? Each line in the text file is not equal in length, so I can not control by bytes ...
    Thanks!

    Since you can't count bytes, there's no way of knowing where to jump except actually reading trough all those preceding lines. (You don't have to store them, though.)
    for(int linenum=0, linenum<jumpTo; ++linenum) {
        reader.readLine();
    }

  • How to highlight a certain line in textArea?

    Hi
    I want to know how can i highlight certain line in atextArea with diffeent colors
    Thanks in advance

    highlight certain line in atextArea with diffeent colorsAre you talking about the foreground or background color??
    If its the foreground, all the text must be the same color. If you need multiple colored text then you need to use a JTextPane.
    If its the background then you can use a Highlighter.
    textArea.getHighlighter().addHighlight(...);

  • Trying to understand what's going on with my line!

    I wonder if someone could help me understand what's happening to my connection.
    I've been on adsl2+ for over a month (since being on a very stable adslmax connection). I'm on a long line 62db atten' and connected at 2890 - same as adslmax which I expected.
    A week ago my connection was reset ( I was unaware) and now connect at 2271 - noise margin is now 13db - always had a stable 6db with no drops.
    The thing I don't get is every time I reboot my router constantly syncs at 2271. Why would it do this? Previously it sync'd at different speeds.
    It's as if I'm now on a fixed rate - but still shows as adsl2+.
    Spoke to bt but they say I have noise on my line and it's in 'acceptable levels' - which it isn't!
    Just want to understand what's going on!
    Thanks

    since the recent software/hardware updates at certain telephone exchanges, when you reboot the router or turn it off constantly, the exchange you are connected to sees it as a fault, and drops your connection to the lowest level possible. your connection then has to physically be  reset by an engineer at the exchange.
    this is what hapenned top me. for the last 8 years i have been on bt, always turning my router off at night, when i had finished, or rebooting it if i had a poor line. since june, my connection speed have been abismal, i stopped at 2420 for about a month (half of that the month before) then over a weel, it dropped to as low as 340kbps - on a 20 meg line.  after going through the help desk, and "you need a new bt homehub router" event though i did not use theirs, phase, and 2 months of stress, i had an engineer come out on Saturday.
    He tested everything (my line is capable of 18.3mb connections). my line was reset ay 8124kbps downstream... 27 hours later, it is on 572kbps, so needs to settle in..allegedly
    to get over this, i am using a BTfon zone connection off one of my neighbours, as it is faster...technology - if you are on option 3, then sign up for it now, as things may get worse.
    welcome to the world of last wednesday week.
    there's now't wrong with 2 cans and a piece of string. at certain times, it is often faster.

  • Screen going crazy, pink horizontal lines, frequent random crashes?

    Hi all,
    First post here... I felt compelled to post as usually Googling a problem will bring me to a solution from one of these discussions but in this case there are many similar instances of my problem but no-one seems to be able to offer an explanantion that fits my particular circumstances.
    I have a late 2011 MBP 15"
    Processor = 2.2 GHz i7
    Memory = 4 GB 1333 MHz DDR3
    Graphics = Intel HD Graphics 3000 384 MB
    OS = OS X 10.9.2
    Recently, my screen started randomly going crazy, all blocky and with horizontal pink lines all over. Then it would go either fully black or fully white. This usually happens when I open another tab or app. Sometimes it crashes and powers off. Sometimes it restarts.
    If it powers off and I restart it or it restarts itself, the horizontal pink lines appear on the startup/spinning gear screen.
    Then the screen goes fully white and the fans go crazy. Now it sometimes just stays hung like this and sometimes it powers off after about 3 minutes of crazy fans.
    I switch it back on and it does the same thing.
    It gets stuck in this loop for ages and often, if I just leave it and come back to it some other time, it powers up just fine however sometimes it will continue to refuse to power up.
    If I try to boot into recovery mode, it blue screens.
    If I try to boot into safe mode, it blue screens.
    If I try diagnositics, it blue screens.
    What could the problem be and how do I fix it?

    I've had a similar issue with my mid-2012 13" non-retina MacBook Pro twice. First time I dropped it and it fell hard ( I mean it fell down a flight of stairs). It sounds like your graphics card and/or logic board and possibly the RAM sticks might have an issue. For me, a new logic board costs about $480 but Apple covered it twice since its less than a year old. Other issues I've had it would have a "checker-board" on startup and it would have a similar glitch when I would move it or set it down. It would also freeze and even shut down. I've also pulled it out of my bag, and it would be a lot hotter than when I put it in. I'd say set up a Genius Bar appointment or take it to a local certified apple service technician or if you really wanted to, setup an appointment and find out what's wrong and then repair it yourself, just make sure your data is backed up. I would suggest back it up to both iCloud and an external hard drive that can hold more data than the internal drive on your mac.

  • Displaying certain Line Items on a Sales Order

    I have sales order with both line items that are populated because we have BOM Items that are marked as u201CSales Relevantu201D items from a production BOM and I also have some items that are line items generated from a true Sales BOM.  The user wants to see the sub items from the Sales BOM on the Sales Order but doesnu2019t want to see the sub items from the u201CSales Relevantu201D Production BOM.  If I select u201Cdisplay range -> main itemsu201D it will hide all the sub items but I really want those sub items with the sales BOM to be displayed.  So I want to be able to display those sub-items that are Sales BOM relevant but not those that are flagged as Sales Relevant on the Production BOM.
    The key element tied to the sales order line item is Item Category do you know if there is a way to automatically display/hide sales order line items based on the Item Category field?
    David

    Kimberly
    If it is standard program and config is done,  it should work by itself. I am wondering why not.   Fine, if it not working, why don't you put a requirement in the output Determination Procedure against the relevant output. You need to copy standard requirement 2 ( Program LV61B002)  and  insert logic to not print if ABGRU  or DRAGR is populated? This will be a 2 minute code to write.
    SPRO/IMG/Sales and Distribution/Basic Functions/Output Control/Output Determination/Output Determination Using the Condition Technique/Maintain Output Determination for Sales Documents/Maintain Output Determination Procedure
    But why don't you leave struggling with reasons for rejection and work with Delivery blocks instead. I suggested this before to somebody else in the forum. I think Delivery blocks (DB)  work  equally well without the bad effect of reasons for rejection (RRJ). Its like this: In stead of deleting an item, use RRJ, In stead of RRJ, use DB. Having said that, I am skeptical that it may also (not) work similar to RRJ. Try it after the Requirement  (above) option.
    If you want to go that 'route' (Pun intended):
    SPRO/Logistics Execution/Shipping/Deliveries/Define Reasons for Blocking in Shipping
    Let me know how it goes.

  • Reading certain lines of a text file and boundary testing ...

    Hi all, 
    This is only my second post so please be gentle ;P
    Basically, my problem is that i want to read certain chunks of a text file into different text boxes. For example, this may be 50 lines in textbox1, then 50 in textbox2, then the rest in textbox3. i know this would involve using a splitter, but i have absolutelyno
    idea how i would go about implementation this. any help would be greatly appreciated on this.
    my second problem is that i also need to carry out testing on my system. one page in this is the login page. I understand that normal data would be all correct fields and erroneous data would be blank field(s). however, i dont really know what would be boundary
    testing for this. The only thing i could think of is correct username but incorrect password but i dont think this is correct. again, any help would be appreciated. 
    thanks, 
    LTID

    Hi all, 
    This is only my second post so please be gentle ;P
    Basically, my problem is that i want to read certain chunks of a text file into different text boxes. For example, this may be 50 lines in textbox1, then 50 in textbox2, then the rest in textbox3. i know this would involve using a splitter, but i have absolutelyno
    idea how i would go about implementation this. any help would be greatly appreciated on this.
    my second problem is that i also need to carry out testing on my system. one page in this is the login page. I understand that normal data would be all correct fields and erroneous data would be blank field(s). however, i dont really know what would be boundary
    testing for this. The only thing i could think of is correct username but incorrect password but i dont think this is correct. again, any help would be appreciated. 
    thanks, 
    LTID
    I suppose there would be a reason for needing to read some amount of lines into each textbox. But you make no mention of why that would be necessary.
    There is such a thing as a delimited text file. Each line would contain a delimiter of some character between fields on each line. That file could be used for displaying information in separate controls on a Form.
    But you only mention TextBox's and reading x amount of lines from a file into each TextBox as if you are perhaps providing certain information for each TextBox.
    If that is what you want then provided replies will work. If you want to explain what you need to do with regard to information in a file and displaying it otherwise then please explain so that a better method could be provided.
    Example using Text Field Parser.
    https://msdn.microsoft.com/en-us/library/microsoft.visualbasic.fileio.textfieldparser(v=vs.110).aspx
    Option Strict On
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (Me.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - (Me.Height / 2)))
    Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("c:\Users\John\Desktop\DelimitedTextFile.Txt")
    MyReader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
    MyReader.Delimiters = New String() {"|"}
    Dim currentRow As String()
    While Not MyReader.EndOfData
    Try
    currentRow = MyReader.ReadFields()
    ListBox1.Items.Add(currentRow(0))
    ListBox2.Items.Add(currentRow(1))
    ListBox3.Items.Add(currentRow(2))
    Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
    MsgBox("Line " & ex.Message & " is invalid. Skipping")
    End Try
    End While
    End Using
    End Sub
    End Class
    Text in text file DelimitedTextFile.Txt. Delimiter is vertical bar.
    Bill|Home Depot|Garden Department
    Cheryll|DirectTV|Installer
    Charlie|C&K Automotive|Owner
    Zorro|Television|Masked Avenger
    Samantha|Mayo Clinic|Nurse Practitioner
    Mona|Bahia Honda Key State Park|Park Ranger
    La vida loca

Maybe you are looking for

  • Grid in drawing

    Hello, i am testing Pages as a AppleWorks user. Where is in Pages the menu to make a grid of for example 1mm (rastering). This would be very helpfull when working with drawing objects. Thanks Achim Message was edited by: Achim Bernlöhr

  • CreditWorthinessQuery_out service interface is not available

    Hello All, We are trying to connect SAP SD with SAP FSCM. Whenever we are trying to create Sales order, it giving error. Actually at this point system is trying to check customers credit worthiness. In sap system , sxmb_moni shows message into error

  • Webservice using Testand.Engine

    Hello, I would like to write a Webservice that monitors my Teststand on demand. The service should be done in C# Here is my Question: Is it possible to access the running Engine ? greetings Juergen =s=i=g=n=a=t=u=r=e= Click on the Star and see what h

  • I would like to make a photo I have available for others to view on the web. How?

    I have a photo that I would like a company to see so they might help me find a duplicate. Is this possible?

  • How do I solve General Error problem when rendering and/or playing part of a sequence?

    Hi! All of a suddenly when I was editing, the General Error message appears. Now there's part of a sequence I cannot render nor play. I've restarted the application and the computer but without result. I've also cleared my render folder. Is there a s