Parse File or String input in a uniform way: Is it possible with Generics?
Yup - that's an abomination.

What you are really looking for is

void parse(Scanner sc) {...}


which can be called from parse(), which passes it the File scanner; and from parse(String), which passes it the string scanner.

It's likely - but not certain - that this method should really be

HashMap&lt;String,String&gt; parse(Scanner sc) {...}


The clue that this might be so is here in your constructor

public Parser(final File path){ 
    /*initialise stuff*/
    val=new HashMap&lt;&gt;();
    source=path; //throws exception if null but omitted for brevity
    /* and finally parse the file */
    parse();
}


You're doing verbing in the constructor, which is a bad sign.  It suggests that Parser is (at different times) responsible for parsing the file and acting as a value type.  Those are two different concerns, and should have two different representations.

Another bad sign is that you are creating Scanners in the same class that is doing work.  Given that in your current interface, you need to create a Scanner, I'm inclined to guess that the refactoring you need is to create a new class that provides the parse(Scanner) implementation.  The existing Parser delegates the work while providing the backward compatible behavior.

If the existing Parser needs more than just key/value pairs, then you might really be looking for

ParseResult parse(Scanner sc) {...}


where ParseResult contains the Map and whatever other state the application needs after the parsing is completed.