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 3 of 3

Thread: Create a method to get integers from a https web page and store them in a array

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Create a method to get integers from a https web page and store them in a array

    I'm new to Java and I'm trying to make a program that can read the integers (listed below) from this link and store them in an array. I've searched around and I can't find any info or working examples of how to do it.

    The integers are:

    17,04,2011,1,2,7,10,13,23,24,25,26,27,38,39,41,43, 45,48,49,55,59,62

    All integers will change each time the method is called. (Different links, same page layout)


    Could anyone help me with the code or point me in the right direction? Maybe someone knows about some good tutorials that explains this?

    Any help is greatly appreciated.


    Regards

    -B


  2. #2
    Junior Member
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Create a method to get integers from a https web page and store them in a array

    This is the first line of error code I get when trying to run any of the examples I've found:
    Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    The code I use in this example is:
    import java.net.MalformedURLException;
    import java.net.URISyntaxException;
    import java.net.URL;
    import java.net.URLConnection;
    import javax.net.ssl.HttpsURLConnection;
    import java.net.URI;
    import java.io.*;
     
    public class Main{
    	public static void main(String args[]) throws Exception {
     
    		//URI uri = new URI("https", "norsk-tipping.no", "/gar/wco", "event=getResultInfo&game_id=13&DrawID=1260&target=1&bet=10&keno_level=10");
    		//URL url = uri.toURL();
    		URL url = new URL("https://www.norsk-tipping.no/gar/wco?event=getResultInfo&game_id=13&DrawID=1260&target=1&bet=10&keno_level=10");
     
    		URLConnection conn = url.openConnection();
     
    		// Retrieve information from HTTPS: GET
    		InputStream istream = conn.getInputStream();
    		int ch;
    		while ((ch = istream.read()) != -1) {
    		    System.out.println("Test" + ch);
    		}
    		istream.close();
    	}
    }
    Does anyone know whats wrong?

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Create a method to get integers from a https web page and store them in a array

    Hello Bøtteknotten.

    Welcome to the Java Programming Forums.

    This error is because you are attempting to connect to a secure HTTPS URL.

    Take a look at these links:

    unable to find valid certification path to requested target : GC - Garbage Collection? GotCha?

    Andreas Sterbenz's Former Blog : Weblog

    They should help you solve your issue
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. How to store objects from a class inn an array?
    By dironic88 in forum Object Oriented Programming
    Replies: 1
    Last Post: April 7th, 2011, 02:42 PM
  2. [SOLVED] Writing Integers to .txt File; Returning Random Characters Instead of Integers
    By verbicidalmaniac in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: March 8th, 2011, 09:42 PM
  3. Replies: 2
    Last Post: January 21st, 2011, 02:07 AM
  4. Store Values in 2D array and output to textarea
    By raverz1tildawn in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 7th, 2011, 03:13 PM
  5. Determine the two smallest integers from a set of user input integers
    By bpontin in forum Loops & Control Statements
    Replies: 4
    Last Post: October 17th, 2010, 06:38 PM

Tags for this Thread