- 浏览: 280682 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
di1984HIT:
学习了。确实不错。、
Eclipse编辑XML自动提示 -
chokee:
可以不行再参考下这一篇http://yubolg.iteye. ...
Eclipse编辑XML自动提示 -
xiaofengtoo:
请问下 你用的什么版本 我用的8.0 版本我的郁闷了 没有Ge ...
ER/Studio使用 -
xp1056:
应该就是这样,可我的不行,我也重起eclipse了,郁闷
Eclipse编辑XML自动提示 -
sxpujs:
这个办法不错
div显示和不显示(当几列数据;<td></td>中显示或不显示)
读取所有的文件数据
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*,java.lang.*"%>
<html>
<head>
<title>读取所有的文件数据</title>
</head>
<body>
<%
String path=request.getRealPath(".");
FileReader fr=new FileReader(path + "file://ReadData.txt/");
//关键在于读取过程中,要判断所读取的字符是否已经到了文件的末尾,并且这个字符是不是文件中的断行符,即判断该字符值是否为13。
int c=fr.read();//从文件中读取一个字符
//判断是否已读到文件结尾
while(c!=-1){
out.print((char)c);//输出读到的数据
c=fr.read();//从文件中继续读取数据
if(c==13){//判断是否为断行字符
out.print("<br>");//输出分行标签
fr.skip(1);//略过一个字符
//c=fr.read();//读取一个字符
}
}
fr.close();
%>
</body>
</html>
一行一行读取数据
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>文件读取</title>
</head>
<body>
<%
String path=request.getRealPath("");//取得当前目录的路径
FileReader fr=new FileReader(path + "file://file//inc//t.txt%22);//建立FileReader对象,并实例化为fr
BufferedReader br=new BufferedReader(fr);//建立BufferedReader对象,并实例化为br
String Line=br.readLine();//从文件读取一行字符串
//判断读取到的字符串是否不为空
while(Line!=null){
out.println(Line + "<br>");//输出从文件中读取的数据
Line=br.readLine();//从文件中继续读取一行数据
}
br.close();//关闭BufferedReader对象
fr.close();//关闭文件
%>
</body>
</html>
略过文件中的字符不读取
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>略过字节不读取</title>
</head>
<body>
<%
String path=request.getRealPath(".");
FileReader fr=new FileReader(path + "file://ReadData.txt/");
fr.skip(2);//跳过2个字节
int c=fr.read();//读取一个字节
while(c!=-1){
out.print((char)c);
c=fr.read();
}
fr.close();
%>
</body>
</html>
将数据写入文件
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>将数据写入文件</title>
</head>
<body>
<%
String path=request.getRealPath(".");
FileWriter fw=new FileWriter(path + "file://WriteData.txt%22);//建立FileWriter对象,并实例化fw
//将字符串写入文件
fw.write("大家好!");
fw.write("本书是《JSP编程技巧》");
fw.write("请多多指教!");
fw.write("email:stride@sina.com");
fw.close();
FileReader fr=new FileReader(path + "file://WriteData.txt/");
BufferedReader br=new BufferedReader(fr);//建立BufferedReader对象,并实例化为br
String Line=br.readLine();
//读取一行数据
out.println(Line + "<br>");
br.close();//关闭BufferedReader对象
fr.close();
%>
</body>
</html>
将写入文件的数据分行
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>将写入文件的数据分行</title>
</head>
<body>
<%
String path=request.getRealPath(".");
FileWriter fw=new FileWriter(path + "file://WriteData.txt/");
BufferedWriter bw=new BufferedWriter(fw);
bw.write("大家好!");
bw.write("本书是《JSP编程技巧》。");
bw.newLine();//断行
bw.write("请多多指教!");
bw.newLine();//断行
bw.write("email: stride@sina.com");
bw.flush();//将数据更新至文件
fw.close();//关闭文件流
out.println("写入文件内容为:<br>");
FileReader fr=new FileReader(path + "file://WriteData.txt/");
BufferedReader br=new BufferedReader(fr);
String Line=br.readLine();//读取一行数据
while(Line!=null){
out.println(Line + "<br>");
Line=br.readLine();
}
fr.close();
%>
</body>
</html>
如何将数据追加写入到文件
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>将写入文件的数据分行</title>
</head>
<body>
<%
String path=request.getRealPath(".");
RandomAccessFile rf=new RandomAccessFile(path + "file://WriteData.txt%22,%22rw%22);//定义一个类RandomAccessFile的对象,并实例化
rf.seek(rf.length());//将指针移动到文件末尾
rf.writeBytes("\nAppend a line to the file!");
rf.close();//关闭文件流
out.println("写入文件内容为:<br>");
FileReader fr=new FileReader(path + "file://WriteData.txt/");
BufferedReader br=new BufferedReader(fr);//读取文件的BufferedRead对象
String Line=br.readLine();
while(Line!=null){
out.println(Line + "<br>");
Line=br.readLine();
}
fr.close();//关闭文件
%>
</body>
</html>
import java.util.*;
import java.io.*;
public class ReadIni
{
public static void main(String[] args)
throws Exception
{
Properties proDB = new Properties();
FileInputStream in = new FileInputStream("DBConfig.ini");
proDB.load(in);
String jdbc = proDB.getProperty("jdbc");
String dburl = proDB.getProperty("dburl");
String userid = proDB.getProperty("userid");
String password = proDB.getProperty("password");
System.out.println(jdbc);
System.out.println(dburl);
System.out.println(userid);
System.out.println(password);
}
}
DBConfig.ini:
dburl=jdbcracle:thin:@202.16.147.104:1521ub
userid=user
password=password
jdbc=oracle.jdbc.driver.OracleDriver
发表评论
-
list vo sort
2010-09-20 14:13 1545一: 只要把需要排序的list传进去(operlist),l ... -
ArrayList和Vector的区别,HashMap和Hashtable的区别
2010-08-17 19:58 890就ArrayList与Vector主要从二方面来说. ... -
Vector、ArrayList和List的异同(转)
2010-08-17 19:56 843线性表,链表,哈希 ... -
fileupload渗透分析(org.apache.commons.fileupload渗透分析)
2010-08-13 11:24 1315fileupload渗透分析(org.apache.commo ... -
Eclipse下Tomcat插件的安装
2010-07-31 16:39 928在Eclipse下安装Tomcat插件使开发,编译,发布变的相 ... -
Set和List
2010-07-19 19:32 1135两个接口都是继承自Collection. List(intef ... -
介绍Java集合类(Collections)
2010-07-19 16:14 945本文介绍了java.util下的接口Collection和 ... -
java汉字转拼音和oracle汉字转拼音
2010-07-06 17:31 2616import java.util.Iterator; ... -
一个关于Exception的基础题
2010-04-26 19:45 917要求大概就是: 1.一个包装了的异常类 packa ... -
Map的几个实现类
2010-04-19 14:19 1035我往一个map里面put一些值,我想要取出来的时候按照put进 ... -
java ReadProperties
2010-04-08 17:26 1506package propertyFile; import ... -
Eclipse编辑XML自动提示
2010-03-19 16:31 20193IED Eclipse Java EE IDE for W ... -
java 日期 加上几天
2009-05-12 17:58 8182String order_end = request.getP ... -
分析日志并按分隔符分开保存
2009-04-20 20:53 1577/** * 读取日志文件地址,每行根据指定字符分割开,每 ... -
子类对象的实例化过程(仅供参考)
2009-04-09 22:28 1440对象中的成员变量的初始化过程步骤如下: 1.分配成员变量的存储 ... -
批量重命名文件
2009-04-08 23:04 1205package com.bob.renameFile; im ... -
父类与子类的静态代码块和构造方法的执行顺序
2009-04-08 23:03 2449package test; /** * 要点: * ... -
使用links方式安装Eclipse插件
2009-04-08 23:02 817eclispe想必大家都很熟悉 ... -
j2se some1
2009-04-08 23:01 8921.格式化日期 Date dt = new Date(); ... -
eclipse ,myeclipse使用 自己总结
2009-04-08 18:16 11141.window->preferences->ge ...
相关推荐
Java 读写文件文本文件的示例
JAVA简单的读写文本文件的代码JAVA简单的读写文本文件的代码
用Java程序实现对.txt文件的读写。txt文件可作为配置文件,以key-Value形式出现。
java 删除某行和读写txt文件 java中貌似没有直接删除某行的方法,这里用的方法是把文件里的内容读出来,写入一个String里,(不要的那行找到,不要写入String),然后再重新写入文件
主要介绍了Android应用程序中读写txt文本文件的基本方法讲解,基本上依靠context.openFileInput()和context.openFileOutput()两个方法为主,需要的朋友可以参考下
Java读写文本文件的示例代码.rar
java读写xml文件 java读写xml文件 java读写xml文件 java读写xml文件 java读写xml文件 java读写xml文件
C#演示以流式方式读写Txt文本文件
JAVA读写二进制文件
JAVA实现创建TXT文件 并执行读写操作
C++读写txt文件,逐行读取,判断并根据判断条件写至输出文件
java读写properties配置文件
Java读写文本文件的示例代码.7z
VC++读写文本文件txt,提供了大量的读写文本文件txt源代码,适合初级VC人员的操作
2. 将内容中的文本写到文件 3. 将一个文件的内容读出来写入另一个文件中 同时也展示了如果从输入流中读出来内容写入输出流中(仅限文本流) 三个例子可以独立存在,所以根据需要只看其中一个就行了
Java读写文本文件的示例代码
java 读写文本文档源码,可自定义文件名称和路径,支持写入中文
java文件读写操作大全java文件读写操作大全java文件读写操作大全java文件读写操作大全java文件读写操作大全
Java IO基础之读写文本文件
Java 读写Ini文件,java读写ini文件的项目小例子。 运行类文件在根目录ini文件夹下src/com文件夹中start.java文件 相关jar包在根目录ini文件夹下bin文件夹中