Return to Snippet

Revision: 1754
at November 10, 2006 00:07 by whitetiger


Updated Code
package get.file.example;

import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

public class GetFileExample
{
	public GetFileExample()
	{
		try
		{
			byte[] bite = new byte[2048];
			int read;
			URL url = new URL("http://switch.dl.sourceforge.net/sourceforge/pys60miniapps/FlickrS60_src_v0.1b.tar.bz2");
			
			BufferedInputStream bis = new BufferedInputStream(url.openStream());
			FileOutputStream fos = new FileOutputStream("/tmp/file.tar.bz2");
			
			while((read = bis.read(bite))>0)
			{
				fos.write(bite, 0, read);
				System.out.println("--");
			}
			
			fos.close();
			bis.close();
			
			System.out.println("FINE");
			
		}
		catch(MalformedURLException e)
		{
			e.printStackTrace();
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args)
	{
		new GetFileExample();
	}
}

Revision: 1753
at November 9, 2006 23:55 by whitetiger


Initial Code
package get.file.example;

import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

public class GetFileExample
{
	public GetFileExample()
	{
		try
		{
			byte[] bite = new byte[2048];
			int read;
			URL url = new URL("http://switch.dl.sourceforge.net/sourceforge/pys60miniapps/FlickrS60_src_v0.1b.tar.bz2");
			
			BufferedInputStream bis = new BufferedInputStream(url.openStream());
			FileOutputStream fos = new FileOutputStream("/tmp/file.tar.bz2");
			
			while((read = bis.read(bite))>0)
			{
				fos.write(bite, 0, read);
				System.out.println("--");
			}
			
			fos.close();
			bis.close();
			
			System.out.println("FINE");
			
		}
		catch(MalformedURLException e)
		{
			e.printStackTrace();
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args)
	{
		new GetFileExample();
	}
}

Initial URL


Initial Description


Initial Title
Python - getFile Internet

Initial Tags
url, image, file, java, python, script, xml, download, text, images, apache, files, Net, directory, aspnet

Initial Language
Python