private String getContentFromPath ( String sourcePath , HostsSourceType sourceType ) throws IOException { String res = "" ; if ( sourceType == HostsSourceType . LOCAL_FILE ) { res = PcFileNetworkIoUtils . readFileContentToString ( sourcePath ) ; } else if ( sourceType == HostsSourceType . URL ) { res = PcFileNetworkIoUtils . readStringFromUrlGeneric ( sourcePath ) ; } return res ; }
note that for read from file this will just load all to memory . not fit if need to read a very large file . However for getting the host name . normally it is fine .