I have a new light fixture I am trying to install. The electrical box has two sets of black and white wires coming in. Both of the black wires are connected together while the white wires from either set were used to connect the old fixture. How should I wire in the new fixture. The switch for this light has only one set of black and white wires connected to the light switch.
Possibly the box was wired using 2-conductor romex as a switch leg. That means one of the blacks is the power into the fixture box. It connects to the other black that goes to the switch. From the switch, the white is used to feed power back to the fixture. Hence you have one white that is neutral and one that is energized. This is not your fault but is 100% wrong, against code and is dangerous for someone like you that is trying to figure out what was done. Switch legs are accomplished using three conductors; one red, one black and one white. Use a current tester and see if you have one white that is hot and one that is neutral. If so, use a black magic marker and color the hot white one black. Do the same where it attaches to the switch.
Identify the wiring so you have the power feed and the switch leg and then put some black tape on the white wire going to the switch. This should be connected to the black power feed and then the white from the power feed is connected to the white of the fixture and the black from the switch leg is connected to the black of the fixture.
If you don't get it, you need to simply hire a qualified electrician so you don't screw up the fixture. Either that or see if there is a wall switch for the fixture for starters. Most people simply put black tape on the white wire that comes back from the switch because it is hot.