Macklin guy Macklin guy - 4 months ago 8
Java Question

Java reading from textfile

Is it possible to read

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

Answer

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");
try
{
    Scanner sc = new Scanner(file);
    while(sc.hasNext())
    {
        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
 }