Macklin guy Macklin guy - 1 year ago 101
Java Question

Java reading from textfile

Is it possible to read

from a text file and somehow put the IP in first arg and port in second arg?
(ip, port)

Answer Source

that is a better way to work with. but this is what you are looking for (i guess)

File file = new File("path/of/your/file");
    Scanner sc = new Scanner(file);
        String line = sc.nextLine();
        String str[] = line.split(":");
        String strIP = str[0]; // this will be the IP Address
        String strPort = str[1]; // this will be the Port Number
}catch(IOException e)
      // work with the errors here
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download