Do you want to use this code or are you seeing it somewhere and want to know what it's doing? If you're seeing CookieHandler.setDefault(); exactly, I would say it's unsetting the system-wide cookie handler.
A CookieHandler is a callback (method) that is used to, well, handle cookies. It is system-wide, so yes, it affects subsequent calls.
All things are lawful, but not all things are profitable.