this code generally works (accesses thousands of urls successfully), but once in a while i get a null pointer exception on particular HttpURLConnections, and its always the same urls
for conciseness ive trunkated the code to only up to where the exception was thrown.

why could this possibly be happening?

//takes an array of urls as strings, makes the requests and sends the results into a specified folder
import javax.swing.*;
import java.awt.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class URLArrayToFiles
	public static void main (String[] args) throws Exception
		//enter urls here to test
		String test[] = {"","","",""};
		new URLArrayToFiles  ("run_from_main\\",test);
	//first paramater saving directory, 2nd paramater array of urls as strings
	URLArrayToFiles (String dirNoSlashes, String[] inAddr) throws Exception
		//make directories if not already exist
		String dirText = "text";
		String dirTarget = "target";
		(new File(dirNoSlashes + dirTarget + "\\")).mkdirs();
		(new File(dirNoSlashes + dirText + "\\")).mkdirs();
		(new File(dirNoSlashes + dirTarget + "\\stats\\")).mkdirs();
		(new File(dirNoSlashes + dirText + "\\stats\\")).mkdirs();
		BufferedWriter targetLog = new BufferedWriter(new FileWriter(dirNoSlashes + dirTarget + "\\" + "stats\\log.txt"));
		BufferedWriter textLog = new BufferedWriter(new FileWriter(dirNoSlashes + dirText + "\\" + "stats\\log.txt"));
		//loop encloses whole program, loops through array of addresses
		for (int i = 0; i < inAddr.length; i++)
			//create prefix for file name for chronological order and for results that do not return a name
			java.text.DecimalFormat nft = new java.text.DecimalFormat("#0000.###");
			System.out.println("result number: " + nft.format(i));	
			//try encloses whole loop, many io exceptions possible
				URL u = new URL(inAddr[i]);
				HttpURLConnection uc = (HttpURLConnection)u.openConnection( );
				//get data for verbose output longest wait in program is here
				int code = uc.getResponseCode( );

        at So
        at So
        at Source)
        at URLArrayToFiles.<init>(
        at InputScreen.actionPerformed(
        at java.awt.Button.processActionEvent(Unknown Source)
        at java.awt.Button.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at Source)
Caused by: java.lang.NullPointerException
        at Source)
        at Sour
        at Source)
        at So
        ... 14 more