Tag Archives: Code

Code to Download File from URL in Java

Below is the code to download the complete contents of a URL to your local hard drive. //IMPORTS import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.io.File; METHOD CODE private static void download(String url) throws … Continue reading

Posted in Java | Tagged , , , , , , | Leave a comment

Best Practices while writing Java code

Usually many of us write the java code in a try-catch block as follows try{ // some code here}catch(Exception e){ // log exception here} Better way to do it is try{ // some code here}catch(Exception e){ // log exception here}catch(Throwable … Continue reading

Posted in Best Practices, Design Pattern, Java, Server Side Programming | Tagged , , | Leave a comment