반응형
package com.lsj.chatting;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * Handles requests for the application home page.
 */
@Controller
public class HomeController {
	
	@RequestMapping(value = "/getServerInfo", method = RequestMethod.GET)
	public void getServerInfo() throws UnknownHostException {
		
		System.out.println("HostName : " + InetAddress.getLocalHost().getHostName());
		System.out.println("Address : " + InetAddress.getLocalHost().getHostAddress());


        String osName = System.getProperty("os.name").toLowerCase();

        System.out.println("os.name property: " + osName);

        if (osName.contains("win")) {
            System.out.println("This is Windows");
        } else if (osName.contains("mac")) {
            System.out.println("This is Mac");
        } else if (osName.contains("nix") || osName.contains("nux") || osName.contains("aix")) {
            System.out.println("This is Unix or Linux");
        } else if (osName.contains("sunos")) {
            System.out.println("This is Solaris");
        } else {
            System.out.println("Your OS is not support!!");
        }
		
	}
	
}
반응형