Patrick O'Sullivan, of 11 Beverly Lane, is charged with first-degree rape, burglary, kidnapping and criminal use of a firearm.
"Obviously anybody who was concerned about him will be relieved now, but we didn't think there was a huge threat to the general public," said Sixth Precinct Det. Lt. William Burke. "It was not random. He had some knowledge of the family that lived at that home."
O'Sullivan allegedly wore a mask and carried a loaded rifle as he entered the home through an unlocked door about 11 p.m. on Nov. 20.
Once in the house, he fired two shots and restrained the woman, binding her hands behind her back with duct tape before raping her, police said.
O'Sullivan had no prior arrests and was not known to the victim, police said.
Burke declined to say how the suspect was identified.
O'Sullivan is being held overnight at the Sixth Precinct and is to be arraigned in First District Court in Central Islip on Sunday.