Any idea how to detect the source code (Java, C #, SQL, etc.) in a Java text file without looking at the file extension or using an unusual long, self-made regular expression?
Perhaps there are some tools that are already doing this work?
LinguistWe use this library on GitHub to detect blob languages, highlight code, ignore binary files, suppress generated files in diff and generate graphs for splitting the language.
We use this library on GitHub to detect blob languages, highlight code, ignore binary files, suppress generated files in diff and generate graphs for splitting the language.
Unfortunately, this is written in Ruby, maybe JRuby can handle this?
, ( ), . , , .
. , , , . , , (SourceCode = true , , SourceCode = false , ). , , , , .
There is an old library, http://sourceforge.net/projects/jmimemagic/ try it, I hope it can give satisfactory results.