How to terminate a method??? Help Please!

Hi, I have the next class which I use to get all the html links from a page passed as url. The problem is that the process terminate with System.exit(). When the class was stand alone this was no problem, but now I need the class being a part of a more complez program and I don�t know how to stop the execution when it gives me all links.
Here is the class:
import java.io.*;
import java.net.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
import java.lang.*;
class getLinks {
final int lim = 100;
int i,cont = 0;
static String links[][] = new String [100][2];
Reader getReader(String uri) throws IOException {
if (uri.startsWith("http:")) {
// Retrieve from Internet.
URLConnection conn = new URL(uri).openConnection();
return new InputStreamReader(conn.getInputStream());
else
// Retrieve from file.
return new FileReader(uri);
public String [][] getHrefs(String url){
EditorKit kit = new HTMLEditorKit();
Document doc = kit.createDefaultDocument();
// The Document class does not yet handle charset's properly.
doc.putProperty("IgnoreCharsetDirective",Boolean.TRUE);
try {
Reader rd = getReader(url);
kit.read(rd, doc, 0);
rd.reset();
ElementIterator it = new ElementIterator(doc);
javax.swing.text.Element elem;
while ((elem = it.next()) != null) {
SimpleAttributeSet s = (SimpleAttributeSet)elem.getAttributes().getAttribute(HTML.Tag.A);
if (s != null) {
links[0] = (s.getAttribute(HTML.Attribute.HREF)).toString(); // Urls
links[i][1] = (elem.getDocument().getText(elem.getStartOffset(), // Desc
elem.getEndOffset() - elem.getStartOffset())).toString();
i++;}
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
return links;
Any ideas? Thanks, Hidra.

Yes, is the logical, but when I remove that line the process never terminate. I don�t know why.

Similar Messages

  • I used utilities to source my 10.6 snow leopard install disc to my main hardrive, and now when I turn on my computer the apple with the spinning wheel stays on the screen and stuck like that. How do I fix it Help please. I already tried all the commands

    I used utilities to source my 10.6 snow leopard install disc to my main hardrive, and now when I turn on my computer the apple with the spinning wheel stays on the screen and stuck like that. How do I fix it Help please. I already tried all the commands such as Command R, Holding down the Option key, C and holding down shift at the start up but nothing happens.
    initialy All I was trying to do was downgrade 10.7 to 10.6 .

    You have to consider the possibility the hard drive may be dying.    If your data isn't backed up, try one of the tools below:
    https://discussions.apple.com/docs/DOC-1689
    Once you are sure your data is backed up, we can examine other possibilities.  In the meantime call AppleCare for your original installation DVDs.  You may need them.

  • My iPad 2 is updated to iOS 6. My question is, can it take panoramic pictures? I tried looking around to see if i could figure out how, but no luck. Help please.

    My iPad 2 is updated to iOS 6. My question is, can it take panoramic pictures? I tried looking around to see if i could figure out how, but no luck. Help please.

    When you look at how they distribute apps it seems that iPods/iPhones are deemed more portable, which is why they have the better camera features, stuff like weather and passbook and stocks, while Apple doesn't seem to plan for the iPad being used as peoples cameras or being carried around with them on a daily basis....and I know evidenc is to the contrary. I've seen people using their iPad as a camera in national parks and at disneyland.

  • Every time an email comes in it's preceded by two telephone rings. I don't know what I did to create the problem so I don't know how to resolve it. HELP PLEASE!!!

    Every time an email comes in it's preceded by two telephone rings. I don't know what I did to create the problem so I don't know how to resolve it. HELP PLEASE!!!

    settings >>>>notifications>>>>Mail >>>>allow notifications >>>off  (your choice )
    settings>>>sounds>>>new mail>>>>none  ( will kill rings )

  • Hi, I have a subscribe button on one of me iWeb pages which is linked to my iPhoto. I don't know how I put it on and I can't find out how to delete it. Help please.....

    Hi, how can I delete a Subscribe button from one of my iWeb pages. I don't remember adding it but it is linked to all of my iphotos and I can't find out how to delete it. Help please...

    I have now sorted my problem thank you

  • Unsatisfied link when callind dll from run method Help Please?

    Hi,
    I get an unsatisfied link error while trying to calling a dll at a certain time period in a run method. The same dll works fine called in another setup and even called in a loop.
    Can anyone help please?
    import java.util.Timer;
    import java.util.TimerTask;
    * Schedule a task that executes once every second.
    public class TimeRetrieve {
        Timer timer;
        public TimeRetrieve() {
                 timer = new Timer();
            timer.schedule(new RemindTask(),
                        0,        //initial delay
                        1*1000);  //subsequent rate
        class RemindTask extends TimerTask
           String string_A;
           double d1;
         double d2;
         double d3;
         double d4;
         double d5;
         double d6;
         double d7;
         double d8;
         int numIter = 3;
         int start = 1;
            public void run()
                  if (numIter > 0) {
                  cinterface(start, string_A, d1, d2, d3, d4, d5, d6, d7, d8 );
              System.out.println("In Java action performed start button, after call to dll  \n");
              System.out.println("   string_A =  :" +string_A );
              System.out.println("doubles , \t  d1  \t d2  \t  d3  \t d4 \t d5 \t d6 \t d7 \t d8");
              System.out.println(d1 +"\t" +d2+"\t"+d3+"\t"+d4+"\t"+d5+"\t"+d6+"\t"+d7+"\t"+d8);
              numIter--;
                 } else
                 System.out.println("End Looping!");
                    System.exit
                 System.exit(0);  
        public static void main(String args[]) {
                   System.out.println("Starting Data Retrieval.");
                 new TimeRetrieve();
    // Load shared library which contains implementation of native methods
                    public native void cinterface(int start, String string_A, double d1, double d2, double d3, double d4,
                    double d5, double d6, double d7, double d8 );
                    static
                          try
                               System.out.println ("load cinterface"); //unsatisfied link
                               System.loadLibrary("cinterface");
                          catch (UnsatisfiedLinkError ee)
                               System.out.println
                                    ("Caught unsatisfied link error for dlls" );
                               System.out.println
                                    ("get local msg = " + ee.getLocalizedMessage() );
                               System.out.println ("getMessage " + ee.getMessage() );
                                   // System.out.println ("print Stack Trace " +ee.printStackTrace() );

    My mistake! I found it. Had some wrong names.

  • My itouch is 4rth gen doesnt have update software in settings and itunes doesnt recognize it how do i update it help please, my itouch is 4rth gen doesnt have update software in settings and itunes doesnt recognize it how do i update it help please

    MY itouch wont update its 4th gen it doesnt hav the software update in settings and itunes wont recognize it how do i update it help please

    Start here:
    iOS: Device not recognized in iTunes for Windows
    or
    iOS: Device not recognized in iTunes for Mac OS X
    Then update via iTunes by:
    iOS 4: Updating your device to iOS 5 or later

  • String Methods Help Please~```

    Hi, I have a question that goes like this:
    Write a Java class called KillWhiteSpace, which defines a main() method that asks the user to enter a String s, and displays a new String consisting of all the characters in s, but with the leading and trailing white space removed. In addition, every sequence of spaces within the String is reduced to one space only. You MUST NOT use any methods defined in the String class other than charAt() and length().
    So far, I wrote
    import java.until.Scanner;
    public class KillWhiteSpace{
    public static void main(String args[]){
    System.out.println("Please enter a bunch of texts");
    Scanner keyboard=new Scanner(System.in);
    String w=keyboard.nextLine();
    Now I know what charAt() and length() does but I don't know how to use it to satisfy the requirements above. Any helps?
    Edited by: Lillian_Cao on Oct 20, 2008 8:17 PM

    I don't want to give you too much since this is clearly an educational exercise, but to get you going, it looks like you you want to iterate over all the characters in the string, analyze each one, keeping track of previous characters and construct your new string as you go.
    Good luck and have fun.

  • Altering a text file using methods, help please!

    Hi I'm new to this forum so please bear with me, my problem is I have written a program for a gym using methods, my program works fine but i need to add another switch (case 5:) to my program, this new switch needs to take the information from case 4: and enable me to change any details and store these changes into a new text file, I know i need a filewriter to store new details into a new text file but i cant figure out how to get the details from case 4: into case 5: and be able to alter these details on screen??, hope this is enough information as to what my problem is. Thnx
    import javax.swing.JOptionPane;
    import java.io.*;
         class GymProgram1
    static void menu(String gym[][])
              int choice = 0;
    while (choice < 1 || choice > 5)
    String input = JOptionPane.showInputDialog("Enter a numerical choice to...\n1: Find customers who smoke, lost weight, use cycles, treadmills, steps, skis or weights \n2: Find customers over a certain age \n3: Find average of all customers \n4: Find a customers details \n5: Exit");
              if (input == null)
              menu(gym);
              try
              choice = Integer.parseInt(input);
              catch (NumberFormatException e)
              switch (choice)
              case 1: search(gym, choice);
                        break;
              case 2: age(gym, choice);
                        break;
              case 3: average(gym, choice);
                        break;
              case 4: details(gym, choice);
                        break;
              default: System.exit(0);
    menu(gym);
    static void search(String gym[][], int choice)
              String output = "";
              int column = 0;
              boolean printed = false;
    switch(choice)
    case 1: int yessearch = 0;
         while (yessearch < 1 || yessearch > 7)
    String input = JOptionPane.showInputDialog("Enter a numerical choice to...\n1: Find customers that smoke \n2: Find customers who lost weight \n3: Find customers who use cycles \n4: Find customers who use treadmill \n5: Find customers who use steps \n6: Find customers who use ski's \n7: Find customers who use weights ");
              if (input == null)
              JOptionPane.showMessageDialog(null, "Cancel pressed");
              menu(gym);
              try
              yessearch = Integer.parseInt(input);
              catch (NumberFormatException e)
         switch (yessearch)
              case 1:     column = 3;
                        break;
              case 2: column = 4;
                        break;
              case 3:     column = 5;
                        break;
              case 4:     column = 6;
                        break;
              case 5:     column = 7;
                        break;
              case 6:     column = 8;
                        break;
              default:column = 9;
         for (int row = 0;row < gym.length ;row++ )
              if (gym[row][column].equalsIgnoreCase("yes"))
              output += gym[row][0] + " " + gym[row][1] + '\n';
              printed = true;
              if (printed == false)
              output = "No data found......";
              display(output);
    static void age(String gym[][], int choice)
              String output = "";
              int column = 2;
              boolean printed = false;
              int ageentered=0;
              int customerage=0;
    String input=JOptionPane.showInputDialog("Enter an age");
              if (input==null)
              JOptionPane.showMessageDialog(null, "Cancel pressed");
              menu(gym);
              try
              ageentered =Integer.parseInt(input);
              catch (NumberFormatException e)
    switch(choice)
    case 2:
         for (int row = 0;row < gym.length ;row++ )
              customerage=Integer.parseInt(gym[row][column]);
              if (ageentered <= customerage)
              output += gym[row][0] + " " + gym[row][1] + " = " + gym[row][2] + '\n';
              printed = true;
              if (printed == false)
              output = "No data found......";
              display(output);
    menu(gym);
    static void display(String output)
         JOptionPane.showMessageDialog(null, output);
    static void average(String gym[][], int choice)
              boolean printed=false;
              String output="";
              int column = 0;
              int counter=0;
              int totalage=0;
              int average=0;
    switch (choice)
    case 3:
              column = 2;
         for (int row = 0;row < gym.length ;row++ )
              counter++;
              totalage+=Integer.parseInt(gym[row][2]);
              printed = true;
              average=totalage/counter;
              if (printed == false)
              output = "No data found......";
              output="Average age = " + average;
              display(output);
    menu(gym);
    static void details(String gym[][], int choice)
              String customer = "";
              String output = "";
              int column = 1;
              boolean printed = false;
    switch (choice)
    case 4: customer = JOptionPane.showInputDialog("Enter a customers surname");
              if (customer == null)
              JOptionPane.showMessageDialog(null, "Cancel pressed");
              menu(gym);
         for (int row = 0;row < gym.length ;row++ )
              if (gym[row][column].equalsIgnoreCase(customer))
              output += gym[row][0] + " " + gym[row][1] + "\n age = " + gym[row][2] + "\n smoke = " + gym[row][3] + "\n weight loss = " + gym[row][4] + "\n cycles = " + gym[row][5]+ "\n treadmills = " + gym[row][6] + "\n steps = " + gym[row][7] + "\n skis = " + gym[row][8] + "\n weights = " + gym[row][9] + '\n';
              printed = true;
              if (printed == false)
              output = "No data found......";
              display(output);
    static String[][] inputData()
              String gym[][] = new String[25][10];
         try
              FileReader file = new FileReader ("a:/assign.txt");
              BufferedReader buff = new BufferedReader(file);
         for (int row = 0;row<gym.length ;row++ )
              for (int column = 0; column < 10;column ++)
              gym[row][column] = buff.readLine();
              buff.close();
         catch (IOException e)
         System.out.println("Error - - " + e.toString());
         return gym;
    public static void main(String[] args)
              String gym[][] = inputData();
              menu(gym);
         for (int row = 0;row < gym.length ;row++ )
              System.out.println(gym[row][0] + " " + gym[row][1] + " " + gym[row][2] + " " + gym[row][3] + " " + gym[row][4] + " " + gym[row][5] + " " + gym[row][6] + " " + gym[row][7] + " " + gym[row][8] + " " + gym[row][9]);
         }

    Thnx for the reply TJ, I'm still confused about this problem, heres what ive done now and i still cant get the details of a customer up on the screen for me to change their details, i havnt pasted the whole program this time just what ive altered in the menu and case 5:, hope you can help.
    static void menu(String gym[][])
              int choice = 0;
    while (choice < 1 || choice > 6)
    String input = JOptionPane.showInputDialog("Enter a numerical choice to...\n1: Find customers who smoke, lost weight, use cycles, treadmills, steps, skis or weights \n2: Find customers over a certain age \n3: Find average of all customers \n4: Find a customers details \n5: Update a customers details \n6: Exit");
              if (input == null)
              menu(gym);
              try
              choice = Integer.parseInt(input);
              catch (NumberFormatException e)
              switch (choice)
              case 1: search(gym, choice);
                        break;
              case 2: age(gym, choice);
                        break;
              case 3: average(gym, choice);
                        break;
              case 4:
              case 5: details(gym, choice);
                        break;
              default: System.exit(0);
    menu(gym);
    static void details(String gym[][], int choice)
              String customer = "";
              String output = "";
              int column = 1;
              boolean printed = false;
    switch (choice)
    case 4: customer = JOptionPane.showInputDialog("Enter a customers surname");
              if (customer == null)
              JOptionPane.showMessageDialog(null, "Cancel pressed");
              menu(gym);
              for (int row = 0;row < gym.length ;row++ )
              if (gym[row][column].equalsIgnoreCase(customer))
              output += gym[row][0] + " " + gym[row][1] + "\n age = " + gym[row][2] + "\n smoke = " + gym[row][3] + "\n weight loss = " + gym[row][4] + "\n cycles = " + gym[row][5]+ "\n treadmills = " + gym[row][6] + "\n steps = " + gym[row][7] + "\n skis = " + gym[row][8] + "\n weights = " + gym[row][9] + '\n';
              printed = true;
              if (printed == false)
              output = "No data found......";
              display(output);
    case 5:
         try
              String display1 = "assign.txt";
              FileInputStream fi = new FileInputStream(display1);
              byte inData[] = new byte[fi.available()];
              fi.read(inData);
              fi.close();
              String text = new String(inData);
              String textToAppend = "kjkjhjhKJ";
              byte outData[] = textToAppend.getBytes();
              FileOutputStream fo = new FileOutputStream(display1,true);
              fo.write(outData);
              fo.close();
         catch(Exception e)
         System.out.println("Error - - " + e.toString());
    display(output);
    menu (gym);
    }

  • I don't know how to get help. Since yesterday 17th October, my Mac is refusing to open copied documents. I can't work, and I don't  understand why this has suddenly happened, or how to stop it. HELP PLEASE

    Dear Mac users, could you please tell me how to get Mac technical support. Thank you very much.

    If you are still under warranty, you can call AppleCare. If not, you can still call them and pay a fee for service.
    Or, you can further explain your problem here and we will try to help.
    What error messages are you getting.
    Where are you copying from and to?

  • On my new iPhone4S I downloaded photos from my MacBook.  I have several duplicates and would like to delete them.  I have not been able to figure out how to do so.  Help please.

    I downloaded photos from my MacBook to my new iPhone4S.  I discovered several duplicates and would like to delete them.  I have not been able to figure out how to do so.  Please help?

    Thanks for your reply.  Although I haven't tried yet, I think I will be able to use the photos on my phone, which have been paired, to find the dups in iPhoto and delete them there.  Previously it was very difficult to search for and find the duplicates on the computer.  Now I should be able to use the paired photos on the iPhone to find and delete the dups on the computer.  Then I will sync the phone again.  I think that should work; I hope you agree.
    xjake

  • How to record a cover help please

    so i want to record my vocals while i hear the audio clip how can i do this?
    because every time i begin to record the backround audio that i put into adobe audtion stops playing. What i want to do is listen and sing along with the audio clip.
    How can i achieve this please help. thanks

    i agree with some of your earlier comments about the notes not been of much help and the course lacking some information. It has taken me almost 9 days to get one to work through a lot of trial and error and a lack of clear details.
    Here are some of the steps (and I am more than happy for anyone to clear these up or add to them!)
    Create a project in Jdev
    sent FND: Diagnostics to yes for your user
    sign into the application that you want to change and go to the page that you want to change.
    At the bottom of the page you will see an about this page link, click on the link.
    THis will open up the page to show the different objects within the page.
    download the BC4J (including the CO/EO objects) components into your <JDEV_HOME>/myclasses using the EXACT same directory structure created on your PC as the one on your apps server.
    Copy the WEBUI items to myprojects using the same directory structure as on the server
    Exapnd all the items on the page and find the item that you want to change which should be linked to a VO. If you click on the VO it should give you something link oracle.apps.icx.etc.etc.
    go to JAVA_TOP on your apps tier and download this file to the correct directory structure. As these files are a mix of class and xml files copy them all to your PC.
    You will have to decompile the class file to get java files (Jad is s good tool to do this). Copy the java files to your project directory.
    You will then have to import these files into your project using File-->Import.
    Hopefully this is a good start.

  • First iPod... and I have no idea how to use it! Help, please!

    Alright, so today I went out and bought a new 80G iPod Classic. So when I get it home, I try to upload some of my music. (About 5G)
    However, I'm on a PC, and all of my music is in Windows Media Player. But when I open up iTunes, it converts some of my music (about 10 albums or so) into my iTunes library. And that's it... The rest of my music is still only avaliable in my WMP library, and of course I can't sync my music to my iPod through that. What do I do? How do I convert my music from WMP to iTunes? I tried going to 'My Computer' and taking my albums and selecting 'send to iPod', however that didn't do anything... except waste an hour or so.
    Also, I have eight or so podcasts downloaded, with various episodes or whatever, but when I tried to sync those only four podcasts appeard on my iPod, with one episode each. Why is this happening?
    And somehow I accidently clicked sync 'contacts' or something when I finally got a iTunes sync screen... but seeing as I don't have my contacts on Microsoft Office Outlook, all I get is an error message. Is there a way I can un-click the box that says add contacts by any chance? I haven't yet found a way to change my sync options.
    Also, how can I upload pictures to my iPod? Is there some software that I need?
    And one last thing: my 'cover flow' doesn't appear to be working. All of my albums have little grey covers. Any idea as to why?
    I'm sorry if some of this stuff is obvious. I appreciate your help. Thanks!

    It sounds like your mom changed a restriction on your device which will not allow you to access content or apps that are rated +12 or higher.  You need to ask your mom to edit the restriction.
    iOS Restrictions:
    http://support.apple.com/kb/HT4213
    iTunes: Parental Controls:
    http://support.apple.com/kb/HT1904

  • Finally I dont understand how to compound regular expressions, help please

    I have read a lot of information about it, but .... I still do not understand how to make compound expresions ....
    How must I use [ ] ?
    Please three examples :
    I want to search :
    - any character but nothing of "abcd"
    - any character but no 'dot' at any position
    - any character but no 'dot' at position 4
    Any good tutorial ?
    Thank you

    The way you have used the word 'search' create some uncertainty in my mind as to what you are asking for. I suspect that what you really want is a 'true' or 'false' that a given string matches some pattern. There are other ways to do this but ...
    "any character but nothing of "abcd" " then use Matcher.matches() using regex "[^abcd]*" .
    "any character but no 'dot' at any position" then Matcher.matches() using regex "[^.]*" .
    "any character but no 'dot' at position 4" then Matcher.matches() using regex "(?!.{3}\\.)" .
    Edited by: sabre150 on Aug 5, 2010 8:50 AM
    Sodding forum markup!

  • I updated my phone and it has deleted the factory apps off of it and i dont know how to get them back help please

    i updated my phone and it deleted everything even the factory apps how do i get them back

    Default apps are part of the iOS and cannot be deleted.  Search all home screens and all folders and/or search for it with Spotlight, that will tell you what folder it's in.
    Also check Settings > General > Restrictions to see if it has been restricted.
    If not found, Settings > General > Reset > Reset Home Screen Layout.

Maybe you are looking for

  • Kitkat broke my photo gallery

    Post-kitkat install on my Razr M, deleted images are "masking" more recent ones.  Images I know I deleted are showing up in the gallery.  When I click on them, they "disolve" while opening to reveal the new image beneath.  It would be a neat parlor t

  • Smart Talk not working with Bluetooth since update

    I have been using Smart Talk for many months now on my iPhone.   I have a bluetooth headset which I generally use.  This has worked fine (with the exception that when I get an incomming call it disconnects the bluetooth from the Smart Talk call). But

  • Can i extend ram upto 2x8=16GB in pavilion dv6-3050tx?

    can i extend ram upto 2x8=16GB in pavilion dv6-3050tx? This question was solved. View Solution.

  • Landscape print

    Hi, We have a requirement to print information in a table manner which requires us to do Landscape prints (as portrait will not hold the information with correct alignment) We are using default Arial font and just updated the "Orientation" to say "La

  • Screen/smc problem, freezing

    i have an Intel imac and yesterday it froze with a bunch of small blue squares showing up all over the screen. Did a force reboot and couldn't get past the user log in screen. Looked around a little, seemed like it might be an smc problem so restarte