怎样读取文件中的ip地址,付给一个变量 ,然后连数据库时只写这个变量 sqlCon=java.sql.DriverManager.getConnection("jdbc:mysql://"+ipaddress+"/vm?user=user1&password=user1&useUn) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 怎样读取文件中一行内容(ip地址),付给一个变量ipaddress ,然后连数据库时只写这个变量 import java.io.*;BufferedReader reader = new BufferedReader(new FileReader(new File("c:\\filename.txt")));String ipaddress= reader.readLine(); <% String Pathstr=getServletContext().getRealPath(""); FileInputStream tfile=new FileInputStream(Pathstr+"\\conndb.txt"); String str=""; int c; while ((c=tfile.read())!=-1) { str=str+(char)c; } int first=str.indexOf(":"); int last=str.lastIndexOf(":"); int lenth=str.length(); String First=str.substring(0,first); String Next=str.substring(first+1,last); String Last=str.substring(last+1,lenth); tfile.close();%> String userip=request.getRemoteAddr();out.print(Userip + " " + Userreq);OK!!!!! 问个土土的乱码问题——中文点号变问号 由isELEnabled ="false"引发的页面无法显示的问题 session的问题 合伙开发校内应用系统 如何存储单挑记录 使用ExpressionEvaluatorManager解析EL出现的问题!!! 有关c3p0的问题,十万火急。下面的程序还有什么问题呢?老是出空指针异常,急死我了 这有什么错? 请高手指点,在JSP中怎么应用XML? 求高人解答,大神来帮下忙 请问如何注册Jbuilder7和Jbuilder8呢? jsp读取ad.txt文件中的一行,并把值给 ipaddress???急!急!急!急!急!
new BufferedReader(new FileReader(new File("c:\\filename.txt")));
String ipaddress= reader.readLine();
String Pathstr=getServletContext().getRealPath("");
FileInputStream tfile=new FileInputStream(Pathstr+"\\conndb.txt");
String str="";
int c;
while ((c=tfile.read())!=-1)
{
str=str+(char)c;
}
int first=str.indexOf(":");
int last=str.lastIndexOf(":");
int lenth=str.length();
String First=str.substring(0,first);
String Next=str.substring(first+1,last);
String Last=str.substring(last+1,lenth);
tfile.close();
%>
out.print(Userip + " " + Userreq);
OK!!!!!