Paradigm.One
Paradigm.One
  • FRAUD DETECTION
  • ACCESS PORTING DATA
  • PARTICIPATE IN PORTING
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Example {
    public static final String LOOKUP1_URL = "http://lookup1.paradigmone.com.au/";

    public static void main(String[] args) throws IOException {
        System.out.println("CAC is " + lookup(args[0]));                
    }

    /**
     * Looks up the mobile service number.
     * 
     * @param serviceNumber - the mobile service number
     * @return String containing the CAC
     * @throws IOException 
     */
    private static String lookup(String serviceNumber) throws IOException {
        HttpURLConnection conn = (HttpURLConnection) new URL(LOOKUP1_URL + "?serviceNumber=" + serviceNumber).openConnection();
        if (conn.getResponseCode() == 200) {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            try (InputStream in = conn.getInputStream()) {
                byte buf[] = new byte[1024];
                int bytesRead;
                while((bytesRead = in.read(buf)) != -1) {
                    bos.write(buf, 0, bytesRead);
                }
                return bos.toString();
            }
        }
        throw new IOException("Failed to lookup service number '" + serviceNumber + "' got " + conn.getResponseCode());
    }
}

Copyright © Paradigm One. All rights reserved.

News
Privacy