Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: problem in calling a method

  1. #1
    Junior Member
    Join Date
    Jan 2018
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default problem in calling a method

    I need a Java API which to call an URL and process what it return for part b in . the programs are what i did for the part a and c.


    a. Enables the entry in a queue of a list of names of astronomical objects then to specify that the seizure is complete (by an empty string for example)
    b. The program reviews the names entered and verifies that they are recognized names by the name resolver Sesam:
    i. If yes we keep the name (or identifier) principal of the object. returns
    ii. Otherwise we do not do anything and we move on to the next.
    c. Finally, this program generates a text file (whose name can be entered) including all

    This is my java program for the first and last part
    Read a string from console using a BufferedReader.

    import java.io.*;

    class BRReadLines {
    public static void main(String args[]) throws IOException {
    // create a BufferedReader using System.in
    BufferedReader br = new BufferedReader(new
    InputStreamReader(System.in));
    String str;
    System.out.println("Enter lines of text.");
    System.out.println("Enter 'stop' to quit.");
    do {
    str = br.readLine();
    System.out.println(str);
    } while (!str.equals("stop"));
    }
    }

    And this one for the third part
    A tiny editor.

    <code>
    import java.io.*;
    class TinyEdit {
    public static void main(String args[]) throws IOException {
    // create a BufferedReader using System.in
    BufferedReader br = new BufferedReader(new
    InputStreamReader(System.in));
    String str[] = new String[100];
    System.out.println("Enter lines of text.");
    System.out.println("Enter 'stop' to quit.");
    for (int i = 0; i < 100; i++) {
    str[i] = br.readLine();
    if (str[i].equals("stop"))
    break;
    }
    System.out.println("\\nHere is your file:");
    // display the lines
    for (int i = 0; i < 100; i++) {
    if (str[i].equals("stop"))
    break;
    System.out.println(str[i]);
    }
    }
    }
    </code>


    Thanks

  2. #2
    Junior Member
    Join Date
    Jan 2018
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default problem in calling a method

    I need a Java API which call an URL and process what it return (i want to verify that the names entered are recognized names in the URL the part b) . the programs are what i did for the part a and c.

    a. Enables the entry in a queue of a list of names of astronomical objects then to specify that the seizure is complete (by an empty string for example)
    b. The program reviews the names entered and verifies that they are recognized names by the name resolver Sesam:
    i. If yes we keep the name (or identifier) principal of the object. returns
    ii. Otherwise we do not do anything and we move on to the next.
    c. Finally, this program generates a text file (whose name can be entered) including all

    This is my java program for the first and last part
    Read a string from console using a BufferedReader.
        import java.io.*;
     
        class BRReadLines {
    	    public static void main(String args[]) throws IOException {
    		    // create a BufferedReader using System.in
    		    BufferedReader br = new BufferedReader(new 
        InputStreamReader(System.in));
    		    String str;
    		    System.out.println("Enter lines of text.");
    		    System.out.println("Enter 'stop' to quit.");
    		    do {
    			    str = br.readLine();
    			    System.out.println(str);
    		    } while (!str.equals("stop"));
    	    }
        }
    And this one for the third part
    A tiny editor.

        import java.io.*;
        class TinyEdit {
    	    public static void main(String args[]) throws IOException {
    		    // create a BufferedReader using System.in
    		    BufferedReader br = new BufferedReader(new 
        InputStreamReader(System.in));
    		    String str[] = new String[100];
    		    System.out.println("Enter lines of text.");
    		    System.out.println("Enter 'stop' to quit.");
    		    for (int i = 0; i < 100; i++) {
    			    str[i] = br.readLine();
    			    if (str[i].equals("stop"))
    				    break;
    		    }
    		    System.out.println("\\nHere is your file:");
    		    // display the lines
    		    for (int i = 0; i < 100; i++) {
    			    if (str[i].equals("stop"))
    				    break;
    			    System.out.println(str[i]);
    		    }
    	    }
        }
    but for the second i dont know how to use SESAM in the program http://cdsweb.u-strasbg.fr/cgi-bin/n...me/-oI?NGC+221
    Thanks
    Last edited by quasarLie; January 10th, 2018 at 02:45 PM.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: problem in calling a method

    Duplicate threads merged.
    i dont know how to use SESAM in the program
    Can you post all the details here so we can see what you are asking about?
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Junior Member
    Join Date
    Jan 2018
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: problem in calling a method

    thanks for your answer, what i want to say by sesam is just the link which contain the list of objects

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: problem in calling a method

    sesam is just the link which contain the list of objects
    Is the program supposed to read an HTML page from a server, find the sesam link and use that to read a list from the server?
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Jan 2018
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: problem in calling a method

    Quote Originally Posted by Norm View Post
    Is the program supposed to read an HTML page from a server, find the sesam link and use that to read a list from the server?
    I want to extrat text from an URL, and then verify if a name of object exist in it.
    I did this to extract a text
    import java.io.*;
    import java.net.*;
     
    public class Demo {
    	public static void main(String[] argv) {
    		try {
    			URL url = new URL("http://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-oI?NGC%20221");
     
    			URLConnection con = url.openConnection();
    			System.out.println(con.getContent());
    			InputStream input = con.getInputStream();
    			while (input.available() > 0)
    				System.out.print((char) input.read());
    		} catch (MalformedURLException e) {
    			System.out.println(e);
    		} catch (IOException e) {
    			System.out.println(e);
    		}
    	}
    }
    But i dont know how to verify if a word exist in it

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: problem in calling a method

    how to verify if a word exist in it
    I assume that the text read from the server via the URL is in a String. The String class has several method that can be used to search a String to see if it contains some text.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Junior Member
    Join Date
    Jan 2018
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: problem in calling a method

    Quote Originally Posted by Norm View Post
    I assume that the text read from the server via the URL is in a String. The String class has several method that can be used to search a String to see if it contains some text.
    can you give me an exemple for one of the method

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: problem in calling a method

    Look at the API doc for the indexOf method for an example

    If you have any questions about the code shown in the API doc, copy it and paste it here
    and ask your questions about it.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Trouble Calling Method
    By Deployment in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 9th, 2018, 06:49 PM
  2. calling method question.
    By jasonrest in forum Object Oriented Programming
    Replies: 4
    Last Post: March 26th, 2013, 06:42 PM
  3. Method not calling?
    By NTWolf1220 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 20th, 2013, 12:04 PM
  4. calling this method
    By antnas in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 2nd, 2012, 01:32 PM
  5. [SOLVED] method calling
    By javapenguin in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 4th, 2010, 01:43 AM