GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Saturday, December 18, 2010

Java IO - Rendering Binary File

To render binary file through remote server like http, use:

import java.net.URL;
import java.net.URLConnection;
import java.io.InputStream;

public class Main{

    public static void main(String[] args){
        try{
            URL image = new URL("http://www.google.co.id/images/"
                               +"srpr/nav_logo27.png");
            URLConnection conn = image.openConnection();
            InputStream input = conn.getInputStream();

            int biner = 0;
            while(biner!=-1){
               biner = input.read();
               System.out.print((char)biner);
           }catch(Exception ex){
               ex.printStackTrace();
           }
        }
    }
}

        
Share/Bookmark

No comments:

Post a Comment