Last active
February 11, 2016 15:27
-
-
Save ChrisGermano/e149056e08aa7a9bcd65 to your computer and use it in GitHub Desktop.
Determines the dankness of your .meme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
public class dankness { | |
public static void main(String[] args) throws IOException { | |
if (!args[0].substring(args[0].lastIndexOf('.')).equals(".meme")) { | |
System.out.println("ERROR - File is not a .meme, aborting."); | |
System.exit(1); | |
} | |
FileInputStream in = null; | |
int foTwennies = 0; | |
int one = 0; | |
int two = 0; | |
try { | |
in = new FileInputStream(args[0]); | |
int c; | |
while ((c = in.read()) != -1) { | |
if (one == 52 && two == 50 && c == 48) { | |
foTwennies++; | |
one = 0; | |
two = 0; | |
continue; | |
} | |
if (one == 0) { | |
one = c; | |
} else if (one > 0 && two == 0) { | |
two = c; | |
} else if (one > 0 && two > 0) { | |
one = two; | |
two = c; | |
} | |
} | |
} finally { | |
System.out.println("File dankness: " + foTwennies); | |
if (in != null) { | |
in.close(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
javac dankness.java
java dankness FILENAME+EXTENSION
Notes:
For easiest usage, run in same directory as the target file.
This will not increase the dankness of the user.