Created
November 12, 2014 12:27
-
-
Save teos0009/2cafd6b177d8fea0944d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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