Skip to content

Instantly share code, notes, and snippets.

@teos0009
Created November 12, 2014 12:27
Show Gist options
  • Save teos0009/2cafd6b177d8fea0944d to your computer and use it in GitHub Desktop.
Save teos0009/2cafd6b177d8fea0944d to your computer and use it in GitHub Desktop.
public void getURL()
{
URL u = null;
InputStream is = null;
DataInputStream dis;
String s;
try {
u = new URL("http://www.singaporepools.com.sg/Lottery?page=wc_four_d");
is = u.openStream();
if (u==null)
{
number.setText("cannot get web page");
}
dis = new DataInputStream(new BufferedInputStream(is));
PrintWriter writeResult = new PrintWriter(new FileWriter(filePath));
if(writeResult == null)
bigamt.setText("filewriter not working");
while ((s = dis.readLine()) != null)
{
writeResult.println(s);
}
writeResult.close();
}
catch (MalformedURLException mue)
{
mue.printStackTrace();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
finally
{
try
{
is.close();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment