资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

java小说阅读器代码 java小说阅读器代码怎么用

java 怎么提取 txt小说里面的章节目录 并记录位置

以下是一些基本的功能代码,读取TXT部分代码来源于网络:

创新互联公司的客户来自各行各业,为了共同目标,我们在工作上密切配合,从创业型小企业到企事业单位,感谢他们对我们的要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。专业领域包括网站设计制作、网站设计、电商网站开发、微信营销、系统平台开发。

public static void readTxtFile(String filePath) {

try {

String encoding = "UTF-8";

File file = new File(filePath);

if (file.isFile() file.exists()) { // 判断文件是否存在

InputStreamReader read = new InputStreamReader(

new FileInputStream(file), encoding);// 考虑到编码格式

BufferedReader bufferedReader = new BufferedReader(read);

String lineTxt = null;

int offset = 0; //章节所在行数

int count = 1; //章节数

ListInfoVo list = new ArrayListInfoVo();

InfoVo infoVo;

while ((lineTxt = bufferedReader.readLine()) != null) {

infoVo = new InfoVo();

offset++;

if (lineTxt.contains("第") lineTxt.contains("章")) {

infoVo.setCount(count);

infoVo.setOffset(offset);

infoVo.setTitle(lineTxt);

list.add(infoVo);

count++;

}

}

System.out.println(list.size());

System.out.println(list.get(0).getCount());

System.out.println(list.get(0).getOffset());

System.out.println(list.get(0).getTitle());

read.close();

} else {

System.out.println("找不到指定的文件");

}

} catch (Exception e) {

System.out.println("读取文件内容出错");

e.printStackTrace();

}

}

public static void main(String[] args) {

// Console.mainMenu();

String filePath = "C:\\20130815.txt";

readTxtFile(filePath);

}

InfoVo结构:

public class InfoVo {

private Integer count;

private Integer offset;

private String title;

public Integer getCount() {

return count;

}

public void setCount(Integer count) {

this.count = count;

}

public Integer getOffset() {

return offset;

}

public void setOffset(Integer offset) {

this.offset = offset;

}

public String getTitle() {

return title;

}

public void setTitle(String title) {

this.title = title;

}

}

怎么用java在nokia6120c上生成一个手机小说阅读器

呵呵,阅读器不是生成的,而是安装的,安装程序是可以网上下载的

在百度中或谷歌中搜索java版的手机阅读器,会找到你所要求的:

另注意:

nokia6120c 操作系统为Symbian S60 第三版因此不太适合安装智能机型版的Nokia Symbian阅读器

但nokia6120c 支持 MIDP2.0 和CLDC1.1

比较合适跑java软件,运行普通java阅读器之类软件多多有余。

请楼主上网上搜索。 注意java版的安装程序是.jad和.jar文件

而symbian版的阅读器为.sis

不要下错了。

哦忘了还有要交待, nokia6120c手机安装上阅读器后,从网上下载文章看是没有问题的,不过我忘了nokia6120c是否支持 jsr75可选包,如果支持的话就能把文章下载到本地空间看。如果不支持的话不仅不能下载到本地,而且会使得引用了jsr75包的安装文件无法安装。 这个就在乎楼主多多尝试一下了,或者上网下载一些对手机java性能进行测试的程序测一下

求安卓大神帮忙,开发小说阅读器,阅读文件的Java代码和导入SD卡文件Java代码

这个google、百度上很多代码啊,随便一搜一大堆。

1.“阅读文件”是指把File读取成String吗?用FileInputStream就可以,参考下面(网上找的):

public static String readFileContentStr(String fullFilename)

{

String readOutStr = null;

try {

DataInputStream dis = new DataInputStream(new FileInputStream(fullFilename));

try {

long len = new File(fullFilename).length();

if (len Integer.MAX_VALUE) throw new IOException("File "+fullFilename+" too large, was "+len+" bytes.");

byte[] bytes = new byte[(int) len];

dis.readFully(bytes);

readOutStr = new String(bytes, "UTF-8");

} finally {

dis.close();

}

Log.d("readFileContentStr", "Successfully to read out string from file "+ fullFilename);

} catch (IOException e) {

readOutStr = null;

Log.d("readFileContentStr", "Fail to read out string from file "+ fullFilename);

}

return readOutStr;

}

2.导入SD卡文件,是指从读取SD的文件吗? 是的话 直接new File(path)就可以得到文件了啊,或者FileInputStream就可以得到流。

怎么用JAVA做个RSS阅读器 求代码

解析XML 希望对你有帮助

public class ParseXML {

//下载一个XML

public void downloadXMLFile(String url,String dir) throws IOException{

//下载的文件夹创建

File ff = new File(dir);

if(!ff.exists()){

ff.mkdir();

}

//爬取指定url下的内容

URL u = new URL(url);

URLConnection uc = u.openConnection();

InputStream is = uc.getInputStream();

BufferedReader br = new BufferedReader(new InputStreamReader(is));

//d:xml

FileWriter fw = new FileWriter(dir+File.separator+getFileNameByURL(url));

BufferedWriter bw = new BufferedWriter(fw);

String line;

while((line=br.readLine())!=null){

bw.write(line);

bw.newLine();

}

bw.close();

br.close();

is.close();

fw.close();

}

//解析xml

public ListNews parseXML(File file) throws DocumentException{

//创建解析器

SAXReader sr = new SAXReader();

//要解析的文件

Document doc = sr.read(file);

//获得跟节点

Element e = doc.getRootElement();

System.out.println(e.getName());

ListNews list = new ArrayListNews();

//从跟节点下查找某节点

ListElement listTitle = e.selectNodes(Common.title);

ListElement listLink = e.selectNodes(Common.link);

ListElement listDesc = e.selectNodes(Common.desc);

ListElement listPub = e.selectNodes(Common.pubDate);

for(int i=0;ilistTitle.size();i++){

News news = new News();

news.setNTITLE(listTitle.get(i).getText());

news.setNLINK(listLink.get(i).getText());

news.setNDESC(listDesc.get(i).getText());

news.setNPUBDATE(listPub.get(i).getText());

System.out.println(listTitle.get(i).getText());

System.out.println(listLink.get(i).getText());

list.add(news);

}

return list;

}

//获取文件名

public String getFileNameByURL(String url){

String[] names = url.split("/");

return names[names.length-1];

}

public static void main(String[] args){

ParseXML px = new ParseXML();

try {

px.downloadXMLFile("", "f://xml");

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

File f = new File("f://xml//rss_newstop.xml");//XML

try {

ListNews list = px.parseXML(f);

NewsServiceImple nsi = new NewsServiceImple();

nsi.insertNews(list, f.getName());

} catch (DocumentException e) {

e.printStackTrace();

}

}

}

java语言框架编写小说阅读器代码

int option = -1;

Object options[] = { "Yes", "No" };

option = JOptionPane.showOptionDialog(frame, "是否退出阅读?", "exit",

JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,

options, options[0]);

switch (option) {

case JOptionPane.YES_OPTION:

System.exit(0);

}

}


本文题目:java小说阅读器代码 java小说阅读器代码怎么用
当前链接:http://cdkjz.cn/article/dodocod.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220