Here you can find the source of readSheBang(Path script)
public static String readSheBang(Path script) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.file.Files; import java.nio.file.Path; public class Main { public static String readSheBang(Path script) throws IOException { try (BufferedReader reader = new BufferedReader( new InputStreamReader(Files.newInputStream(script), "UTF-8"))) { String line = reader.readLine(); while (line != null) { line = line.trim();//from www . j ava2 s .c om if (line.length() > 0) { if (line.startsWith("#!")) { return line; } else { // Not found return a default value return "#!/bin/sh"; } } line = reader.readLine(); } // Not found return a default value return "#!/bin/sh"; } } }