How can i get program to wait until file is loaded?

Hi all,
I keep getting a null pointer exception error thrown when it shouldn't. I'm 99% certain that its being generated because the program speed is faster than the load file time. Is there any way to make the program wait until the file is finished loading? I know you can set up a for loop that will take up some time but I wanted it to be more accurate so that no errors will occur on any machine. Here is the code
RunMainProg();
          String[] TempHolder = new String[HowMany*2];
          try
              BufferedReader readerOne = new BufferedReader(new FileReader("TempMDLFile.txt")); // file just save from RunMainProg()
              String lineOne;
              int i=0;
                   while ((lineOne = readerOne.readLine()) != null)
                        if(i>=TempHolder.length)
                        break;
                         TempHolder=lineOne;
                         i++;
          readerOne.close();
               catch (IOException f)
                    MakeDialog ErrorDialog = new MakeDialog(TopWindow, "Load Error", "Error - The file you entered does not exist", "Error", "OK", "OK", 0, 0);
               for(int i=0; i<TempHolder.length; i++)
                    if(TempHolder[i] == null)
                    i=0;
               FormatData TestSequences = new FormatData(TempHolder); // problem occurs at this line
I have looked all over and can't seem to find a way to verify if the file is loaded, or to get it to wait until it has. Any help would be much appreciated. Especially if you can supply some code snippets :)
Much obliged
Drb2k2

okay, I added some test code that I was using to try and iron out the problem. Perhaps its best if I run through what happens.
1. I get the data from the text box, and an external program is run which generates some text files. These files are then loaded and examined and some new data is appended to the old. This is the process
FormatData TestSequences = new FormatData(TempHolder); Now every time its run first time around its fine.
2. When I try and do exactly the same thing with the new appended set of data the null exception is thrown. Now Dr Clap, I thought exactly the same as you did, but... If i add the following bit of code before the FormatData call..
for(int i=0; i<TempHolder.length; i++)
System.out.println(TempHolder);
It will produce the data without the appended info, and some null sequences.
The size of TempHolder is adjusted depending on the amount of data submitted, so somewhere along the line its just not working.
3. Now for the fun part, eventually if you put the call in a loop it will correct itself and produce the outcome, but needless to say i'd rather not have my program catching a load of nullpointerException errors.
Finally as for the code
for(int i=0; i<TempHolder.length; i++)               {                    if(TempHolder[i] == null)                    i=0;               }That was an attempt to stall the program until no null sequences were found. Sort of getting around the problem in 3.
Dr Clap is a legend on these posts and his advice is well recieved but I have no idea how to view a stack trace or what benefit it has. Any tips on this would be great.
Thanks for your help so far
drb2k2

Similar Messages

  • I just bought PSE 11. Serial No. accepted but Error appears, preventing me to install. What is wrong OR, how can I get program installed?  I've tried at least four times!!  Jim H.

    I just bought PSE 11. Serial No. accepted but Error appears, preventing me to install. What is wrong OR, how can I get program installed?  I've tried at least four times!!  Jim H.

    Use the instructions here to completely remove/uinstall all iTunes/Apple software and componenets and then start from scratch.
    http://support.apple.com/kb/HT1923
    B-rock

  • How can I get rid of a music file use in a menu?

    How can I get rid of a music file use in a menu? I try to get rid of it from the menu inspector but although I delete it there, it is still in use by the menu!
    it is not inthe audio window in the menu inspector but is still in use! wiered!

    Click on the menu with the audio, then look in the property inspector, under the 'general' tab.
    Towards the bottom there is the list containing the audio file for the menu - click on the file and use the '-' button in the bottom left corner of the PI...

  • I have created my magic movie how can I get it to a mpeg4 file

    I have created my magic movie, can I share this with I tunes ect, and how can I get it to a mpeg4 file?

    Are you referring to Magic DVD rather than Magic Movie?  If so you really can't go from an iDVD project to iTunes.  You would need to create a slideshow in iPhoto and export it out as a QT movie before importing into iTunes
    or create the slideshow/movie in iMovie and Share directly to iTunes:
    What system, iDVD and iPhoto versions are you running?  What is the media, i.e. photos or movie files, that you used in the iDVD project?
    OT

  • How can I get Thumbnails back in the file View Menu?

    My computer died and I had to re-install CS6.  I had originally installed it to an external hard drive expecting that I could just hook up a new computer when the time came and everything would work as before.   Not to be.   I contacted Adobe and got the program re-installed.  Now, when I open a file, I am unable to change the view in the View Menu to 'thumbnail' because 'thumbnail' is no longer an option.  How can I get that option back?
    Thank you.

    Are you talking about in the File>Open dialog in photoshop cs6?
    Could you post screenshot of what you see?
    Windows 7 doesn't have a thumbnail option as windows xp, but you should be able to at least see the jpeg thumbnails without any third party programs.
    If you pick Tiles or one of the three Icon options at the top, your not able to see the jpeg thumbnails?

  • How can I get back the default system files icons to my fles?

    Hello,
    After installing an application like FontExplorer, all my fonts got it's icon.
    I went to a font, selected and did get info, I tried to delete the icon but could not.
    I know the default icons for OTF fonts and an italic O, half green, half black.
    How can I get those Icons back,
    Or in general,
    When files gets an application icons, how can I restore the default icons for files?
    Thank you
    Shlomit

    Icons in the Get Info pane can be changed back to the original icon by clicking on the icon once, to highlight it, and then pressing Control X (for cut).
    But in your case the font icon is probably more due to the association with the application selected to open it with, ie FontExplorer. So with the Get Info pane open for a selected font type you need to change which application you use to open it with. For example, if you select one of the OTF fonts and do a Get Info, in the Open With pane it will show FontExplorer. Change this to Font Book and it should change its default icon.

  • Cisco NSS324 - how can I get a list of opened files - similar to psfile

    I have a Cisco NSS324. I need to determine what files are open and by what users.
    I have AD integration - so the users I am looking for are Windows users.
    for Windows servers we are using 'psfile' - how can we get a similar tool that works with the Cisco NSS324?
    thank you
    Calin

    Calin,
    Not to familar with window server using psfile. I know of a feature i use in the NSS to give me an idea what local/domain user are accessing. Under Administration-->System log settings click on System connection logs--> click options and select protocol you would like to monitor and then start logging. This will display any users accessing the NSS and there accessed resources. You can also send this information to your local syslog server and save the copy to your local NSS .
    Hope this helps,
    Jasbryan

  • How can I get my Illustrator cs4 original file settings?

    My Illustrator cs 4 settings files have been corrupted by a virus and I need them so I can create a new document.  How can I get them? So far, I can't create a new document because of this problem.

    Yes. You can change the Language you want installed using the Adobe Application Manager (AAM). You will need to uninstall the language you currently have before switching. Click on your name in the top left of AAM to access the Preferences menu which has the Language setting.

  • How can i get all links from html file ?

    I tried some code:
    List<string> metas = new List<string>();
    string text = "";
    string mys = "";
    public List<string> LockedThreads(string filename)
    HtmlWeb web = new HtmlWeb();
    HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
    doc.Load(filename, Encoding.UTF8);
    var metaTags = doc.DocumentNode.SelectNodes("//meta");
    if (metaTags != null)
    foreach (var tag in metaTags)
    if (tag.Attributes["name"] != null && tag.Attributes["content"] != null)
    text = tag.Attributes["name"].Value;
    mys = tag.Attributes["content"].Value;
    var linksOnPage = from lnks in doc.DocumentNode.Descendants()
    where lnks.Name == "a" &&
    lnks.Attributes["href"] != null &&
    lnks.InnerText.Trim().Length > 0
    select new
    Url = lnks.Attributes["href"].Value,
    Text = lnks.InnerText
    foreach (HtmlNode node in doc.DocumentNode
    .SelectNodes("//a/@href | //img/@src"))
    metas.Add(node.Name);
    In the var linksOnPage i'm getting all the links but some of them not only links for example the first item i see:
    [0] = { Url = "/", Text = "&nbsp;&nbsp;&nbsp;&nbsp;" }
    Then the second item:
    [1] = { Url = "http://rotter.net/cgi-bin/forum/dcboard.cgi?az=login", Text = "התחבר" }
    Next i want to add another loop or variable that will contain only the links after im src for example:
    <img
    src="http://mysite.com"
    border="0"></a></TD><TD
    ALIGN="right"
    VALIGN="TOP"
    WIDTH="55%">
    So to get only http://mysite.com
    So in the end i will have two Lists:
    First List will contain all links from the html file.
    Second List only links that are in img src

    Ok i'm using regex now and i can get the links i need:
    List<string> metas = new List<string>();
    List<string> metas1 = new List<string>();
    string text = "";
    string mys = "";
    public List<string> LockedThreads(string filename)
    string[] fall = File.ReadAllLines(filename);
    foreach (string hh in fall)
    if (hh.Contains("http://rotter.net") && hh.Contains("locked")||
    hh.Contains("locked_icon_general") ||
    hh.Contains("locked_icon_anchor") ||
    hh.Contains("icon_anchor") ||
    hh.Contains("locked_icon_fire") ||
    hh.Contains("locked_icon_sport")||
    hh.Contains("locked_icon_camera")||
    hh.Contains("locked_icon_movie"))
    Regex linkParser = new Regex(@"\b(?:https?://|www\.)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
    foreach (Match m in linkParser.Matches(hh))
    metas.Add(m.Value);
    So now in the metas i have in this case two links.
    For example the first link is from this block in the file:
    The link i got is : http://rotter.net/forum/Images/hot_icon_anchor.gif
    And this is the right link from this block but now how do i get the text from this block and how i connect how do i know that this text belong to the link ? I need to add this text from this block to a new List. Before all that i counted on my own lines
    and got the text but that's a bad idea.
    I need somehow to get: שרשור תשדירי בחירות מרוכז:
    To get the text between the ToolTip',' and the second ',' but not from all the html file only in places of this two links i extracted.
    <TD ALIGN="RIGHT"
    VALIGN="TOP">
    <body onmousemove="overhere()">
    <a onmouseover="EnterContent('ToolTip','שרשור תשדירי בחירות מרוכז:','<u><span style=color:#000099;>כתב: menahem בתאריך: 03.03.15
    שעה: 08:51</span></u><br>1.<br>http://youtu.be/utUaqyiRkJ8<br><br><br>...'); Activate();"
    onmouseout="deActivate()"
    href="javascript:void(0)">
    <img src="http://rotter.net/forum/Images/hot_icon_anchor.gif"
    border="0"></a></TD><TD
    ALIGN="right"
    VALIGN="TOP"
    WIDTH="55%">
    <FONT CLASS='text15bn'><FONT
    FACE="Arial">
    <a href="http://rotter.net/cgi-bin/forum/dcboard.cgi?az=read_count&om=187966&forum=scoops1"><b>
    <font color="red">שרשור תשדירי בחירות מרוכז:</b>
    </a></font></TD>

  • How can I get an extension from a file...in JFileChooser

    I have got a problem here. Here I have a JFileChooser, I want to add in
    a FileFilter, and user could only see some type of file. But as long as I
    try to get the extension....It wont compile, could any one teach me how
    to get the extension of a file in JFILECHOOSER???
    ============================================
    import java.io.*;
    import java.io.File.*;
    import javax.swing.filechooser.FileFilter;
    public class MainFrame extends JFrame implements ActionListener {
    public MainFrame() {.............}
    private boolean chooseFile()
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
    FileChoser filtering = new FileChoser("txt");
    fileChooser.setFileFilter(filtering);
    fileChooser.addChoosableFileFilter(filtering);
    int selection = fileChooser.showOpenDialog( this );
    if ( selection == JFileChooser.CANCEL_OPTION )
    return false;
    if (selection == -1) {
    return false;
    File tmpfile = fileChooser.getSelectedFile();
    filename = tmpfile.toString();
    setTitle( "Smiggin Holes 2010 - " + filename );
    return true;
    static class FileChoser extends javax.swing.filechooser.FileFilter
    String extension;
    String description;
    public FileChoser(String extension, String description){
    this.extension = extension;
    this.extension = description;
    // Accept all directories and all gif, jpg, or tiff files.
    public boolean accept(File f)
    if (f != null)
    if (f.isDirectory())
    return true;
    String ext = getExtension(f); //<<<<<<<<<<<THE PROBLEM IS HERE WHEN I TRY TO GET THE EXTENSION OF THE FILE. IT CANT COMPILE
    System.out.println("aasdfasdf"+ext);
    if ((ext!=null)&&(ext.equals(extension)))
    return true;
    return false;
    // The description of this filter
    public String getDescription() {
    return "Just Text Files";
    ======================================
    Could you tell me what can I do? To get the extension of the file selected by the user?
    And What do I have to change?
    Regards,

    Hi,
    can you post your compile error and the code of getExtension().
    Regards
    Ldinka

  • My daughter reset my iphone4. How can I get back recorded memos = sound files? Thank you!

    To make things more complicated: I "drowned" my iphone last summer and got a new one (also an i phone 4) in November. When I signed in yesterday after the reset mishap, suddenly old data photos, sound memos from the old phone which I had thought lost were available - although the phone displayed the new (November 2012) apps, too. So I may have logged in with the old (drowned) account and password. How can I log out and be forced to login with the new apple ID to check and - more important - to get reicent sound file memos back? I don't want to risk to delete them.
    Thanks for your help and sorry about my struggling in English.

    if you want Lenovo's version of the Windows 8, you would need to call the Lenovo Service support in your country.
    If you want generic Windows 8 version then you need to get the disc from somewhere (i.e. friend) or purchase it.
    Regards,
    Jin Li
    May this year, be the year of 'DO'!
    I am a volunteer, and not a paid staff of Lenovo or Microsoft

  • How can I get Firefox to open htm files?

    I have Firefox 3.6.13, and Windows XP. I can't open htm files. I went online, and followed all the directions for Changing the Default Program for a Specific File Extension in Windows XP, and see that Firefox is listed as the program that should open htm files, but I get a blank page when I try to open the file.

    Are that files that you have saved on your computer or web pages that you try to open?
    Are you opening the files with a double-click in Windows Explorer?
    See also http://kb.mozillazine.org/Windows_error_opening_Internet_shortcut_or_local_HTML_file_-_Firefox
    There are other things that need attention:
    Your above posted system details show outdated plugin(s) with known security and stability risks that you should update.
    # Shockwave Flash 10.1 r82
    # Next Generation Java Plug-in 1.6.0_21 for Mozilla browsers
    Update the [[Managing the Flash plugin|Flash]] plugin to the latest version.
    *http://www.adobe.com/software/flash/about/
    Update the [[Java]] plugin to the latest version.
    *http://www.oracle.com/technetwork/java/javase/downloads/index.html (Java Platform: Download JRE)
    Update the [[Adobe Reader]] plugin to the latest version.
    *http://get.adobe.com/reader/otherversions/

  • How can I get command+down to open files again?

    For as long as I can recall command+down arrow would open files in the finder. It seems this is no longer the case in 10.6.
    I've tried adding an application shortcut to Finder in the Keyboard System Preference pane but it doesn't seem to have any effect.
    Anyone know how to get it back?

    Following your suggestion I moved all com.apple.*.plist files to a temp folder on my desktop.
    Log out. Log in.
    Keyboard shortcuts were fine.
    From there I moved the plist files back in groups of 12, overwriting any existing files. Log out. Log in. Repeat.
    com.apple.symbolichotkeys.plist was the culprit.

  • How can I get IFO, BUP and VOB files to play on my iPad

    I have a DVD of my vacation that a friend made using iMovie. But I can't get it to load on my iPad to play. Any idea how to do this cheaply?

    You don't.
    Those are DVD format files and are not playable on any ios devices. 
    You will have to use handbrake to convert the video on the dvd to a compatible format. 

  • How can I get the size of a file with apple script

    I try to get the size of a file within an apple script. But I did not find information how to do this.

    There are two ways. I think Apple is moving toward using System Events, which is listed first.tell application "Finder"
    set myFile to selection as alias
    --this just gets a file for me to work with
    --coercing it into an alias is required for the other functions
    end tell
    tell application "System Events"
    get size of myFile
    end tell
    set myInfo to (info for myFile)
    get size of myInfo

Maybe you are looking for