📄 snmphelper.java
字号:
package com.sitech.net.topo.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class snmpHelper {
/**
* 得到snmp的ip地址
*
* @return
*/
public String getSnmpIP() {
String result = "";
InputStream input = getClass().getResourceAsStream("/snmp.properties");
Properties prop = new Properties();
try {
prop.load(input);
result = prop.getProperty("snmp_ip");
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
public int getSnmpPort() {
int int_result = 161;
String result = "161";
InputStream input = getClass().getResourceAsStream("/snmp.properties");
Properties prop = new Properties();
try {
prop.load(input);
result = prop.getProperty("snmp_port");
int_result = Integer.parseInt(result);
} catch (IOException e) {
e.printStackTrace();
}
return int_result;
}
public String getSnmpCommunity() {
String result = "";
InputStream input = getClass().getResourceAsStream("/snmp.properties");
Properties prop = new Properties();
try {
prop.load(input);
result = prop.getProperty("snmp_community");
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
public int getSnmpRetries() {
int int_result = 3;
String result = "3";
InputStream input = getClass().getResourceAsStream("/snmp.properties");
Properties prop = new Properties();
try {
prop.load(input);
result = prop.getProperty("snmp_retries");
int_result = Integer.parseInt(result);
} catch (IOException e) {
e.printStackTrace();
}
return int_result;
}
public int getSnmpTimeout() {
int int_result = 2000;
String result = "2000";
InputStream input = getClass().getResourceAsStream("/snmp.properties");
Properties prop = new Properties();
try {
prop.load(input);
result = prop.getProperty("snmp_timeout");
int_result = Integer.parseInt(result);
} catch (IOException e) {
e.printStackTrace();
}
return int_result;
}
public static void main(String args[]) {
snmpHelper helper = new snmpHelper();
System.out.println(helper.getSnmpIP());
System.out.println(helper.getSnmpPort());
System.out.println(helper.getSnmpCommunity());
System.out.println(helper.getSnmpRetries());
System.out.println(helper.getSnmpTimeout());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -