Skip to main content

If Life

If life had the ability to reach out to us, would we allow it? I think not. I believe life has many things wrong with it. Some things are quite complex while other things are easy as apple pie. (However easy that is!) It doesn’t feel like it’s something to be proud or ashamed of. It just is.

Other kinds of Argument checking

So we've talked about a possible argument checking in Java. What if you just want to pass in files to be worked on?

That's simple enough, just loop through your argument array and perform the work on the files in question. Here's a simple way of doing that.

public static void main(String[] args) {
    for (String arg : args) {
    	doSomethingSpecial(arg);
    }
}

You can easily save the results back out to the same file as well since you will have that current argument in your posession. Easy right? Yeah something like that.

What if you want to perform an action based if an argument is passed in?

Let's say that you pass the filename as the first argument, then you pass the operations you wish to perform on that argument in the following arguments.

You can easily get the first argument by doing args[0], and then you can put the remaining arguments in a HashSet and check one by one if the specified argument is there. If it is, then perform the specified operation on it that you define in your codebase. Let me see if I have an example of this:

public static void main(String[] args) {
        Set arguments = new HashSet<>(Arrays.asList(args));
        if (arguments.contains("doit")) {
            System.out.println("Doing it!");
        }
    }

Yep I did have an example. How's that for something? It all works out in the end. You can of course modify the code based upon whatever circumstance you need to work with.

Comments

Popular posts from this blog

Schizoaffective Disorder

I want to say it first began in High School when I thought I was trying to beat the devil. Now when I say I was "trying to beat the devil", I mean I actually thought I was hearing the devil speak to me at night and that I had to find some way to overcome him. Looking back I should have sought professional help then. I remember telling a friend about this experience, and he looked at me like I was nuts. Talk about craziness right? Yeah something like that. I believe my first mental break was when I was serving a mission for The Church of Jesus Christ of Latter-Day Saints . I wanted to go home so bad. It could have just been homesickness . But...there was something more to it. About halfway through I was just done with it all. I had had enough of rejection and wanted to go home. But I was afraid that I was unable to because I would simply be told no . I know that sounds silly to people. But that's what happened. I didn't b...

Smallville Season 4 Episode 1

Okay, so I’m starting Season 4 and am on Episode 1. We meet Lois Lane, that’s Chloe’s cousin. She comes to Smallville to try and track down what happened to Chloe. Meanwhile, Clark comes falling out of the sky in a bolt of lightning. Yup he’s naked in a cornfield. On top of that he has amnesia. Yeah … Clark doesn’t remember who he is. Later on he thinks he’s Kal-El, even goes flying after some kind of crystal Lex has. But his mom brings him back down to Earth, literally as he was seen flying earlier in the episode. Good ol’ Black Kryptonite given to her by Margot Kidder, who played the original Lois Lane in the Superman movies. (I love how this show brings in guest stars like this.) So Clark is back to normal and he remembers flying, saying it was “awesome.” His dad wakes up from his coma and Lois tries to forge a connection with the Kents so she can hopefully find something out about her cousin Chloe’s death. Yeah I enjoyed the season opener. Can’t wait to see what happens in this...

Temptation Bible vs Book of Mormon

In the Bible in 1 Corinthians 10:13 we find: There hath no temptation taken you but such as is common to man: but God is faithful, who will not suffer you to be tempted above that ye are able ; but will with the temptation also make a way to escape, that ye may be able to bear it. But what might seem as a contradiction is found in Alma 13:28 But that ye would humble yourselves before the Lord, and call on his holy name, and watch and pray continually, that ye may not be tempted above that which ye can bear , and thus be led by the Holy Spirit, becoming humble, meek, submissive, patient, full of love and all long-suffering; So, which is it? Either God tempts you to a point and stops, or you have to actively pray not to be tempted beyond that no return point. Which is it?