Before trying to figure out how to do something in a language you are not too familiar with. Check existing code. Chances are very likely someone has already written it before or at least very similar to what you are trying to do. I spent a good couple of hours checking online before I found the very thing I wanted to do in a different class for automation test I was creating.
I enjoy growing software and experiencing life.