Installing an electrical outlet in my attic?
If the cable is feeding a typical residential circuit, and if it's not already at legal capacity (which is fairly flexible in many cases), and if there's no other weirdness at play, yes. 

If you're not lucky enough to have two feet of slack you may need to use two junction boxes. Cut the wire between two boxes and pull it into each of them. Run a new length of wire between, and splice in your new outlet leg from one box. It's more or less blacks to blacks and whites to whites. Junction boxes must remain accessible. Secure all cables appropriately (and within a foot of each box).