I am trying to read a remote file in java
File f = new File(\"//192.168.1.120/home/hustler/file.txt\");
The remote machine needs a Username
Another alternative with jCIFS you can easily specify authentication parameters:
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domain", "user", "password"); // Authentication info here, domain can be null
try (InputStream is = new SmbFile("smb://192.168.1.120/home/hustler/file.txt", auth).getInputStream()) {
// Read from 'is' ...
} catch (IOException e) {
// Handle IOException
}