java 关于将ArrayList存入文件与读取的问题

问题描述:这段代码是我未完成的主文件,本人java初学者,实在无法解决,渴求帮助。
这段程序是为了记录Task这个class并保存在timetracker.data中。程序首先要读取文件中的内容,我根据ObjectInputStream函数,想将文件内的内容的全部作为一个ArrayList整体读取出来,然后再在用户输入1时使用add()直接将新的Task添加到ArrayList中,最后在用户输入5的时候将这个ArrayList作为一个整体保存进去。以此来实现Task这个class的存取。 目前来看我的问题出在TaskList = (ArrayList)ois.readObject();这一行。
编译时会警报 未经检查的类型使用,找到java.lang.Object 需要java.util.ArrayList
我的疑问是 到底能不能通过readObject将文件内的所有内容读出,还是只能读出一个然后我的程序强行将这个Object转化成了ArrayList形式。
如果能,希望可以教我一下我写法的缺陷。
很抱歉浪费大家时间,感激不尽

import java.io.*;
import java.text.*;
import java.util.*;
import java.lang.*;

public class TimeTracker
{

public static void main(String[] args)  throws IOException
{
byte[] option = new byte[100];

ArrayList<Task> TaskList = new ArrayList<Task>();
for(;;){    //nihao

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

ObjectInputStream ois = null;


try{
ois = new ObjectInputStream(new FileInputStream("timetracker.data"));
TaskList = (ArrayList<Task>)ois.readObject();

}  catch (ClassNotFoundException e){
    System.out.println("(None)");
} catch (EOFException e){       // catch EOF
System.out.println("have reached the end of file");
}   

finally{
    if( ois != null )
        {
        ois.close();
        }
int n = TaskList.size();
System.out.println(n);

    }

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

ManuPrint manu = new ManuPrint();
manu.Print();

int numRead = System.in.read(option);
if((char) option[0] == '1'||(char) option[0] == '2'||(char) option[0] == '3'||(char) option[0] == '4'||(char) option[0] == '5'){
if((char) option[0] == '1'){
System.out.println("Enter new task (blank line ends input, no text ends the current task):");
Date date = new Date();
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat dt = new SimpleDateFormat("HH:mm");
//------------------------------record the last finished task

//------------------------------record the last finished task
// still not sloved multi lines
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = null;
str=br.readLine();  
// multi lines

Task a = new Task((ft.format(date)),(dt.format(date)),"","",str);




TaskList.add(a);




}   // option 1

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if((char) option[0] == '5'){
FileOutputStream fout = new FileOutputStream("timetracker.data");
ObjectOutputStream out = new ObjectOutputStream(fout);
try{

out.writeObject(TaskList);
out.flush();
} catch(Exception e){
e.printStackTrace();
} finally{
try{
    out.close();
} catch(Exception e){
    e.printStackTrace();
    }
}

System.out.print("******SEEEEEE UUUUU NEEEXT TIMEEE*********");
    System.exit(0);
}   // option 5

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
} // if=1,2,3,4,5
else{
System.out.println("Invalid option!");
continue;
}
} //nihao
} // main
} //class

2个回答

首先,分析下报错的这行代码,因为你既然使用的是readObject,那么你的文件timetracker.data中必须存的是通过java序列化的一个ArrayList对象,然后writeObject写到这个文件中的。
所以,你的问题可能是这个文件中的东西并不是序列化的ArrayList类型的对象。你需要另写一个类线序列化一个对象向文件中存入标准的对象流,然后再执行你这段代码才行。
我的简单测试案例:先写,再读。

 import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

public class SerialiTest {
    public static void main(String[] args) {
        SerialiTest serial = new SerialiTest();
        //先序列化对象写入文件
        serial.writeFirst();
        //再反序列化读取对象
        serial.readAfter();
    }

    public void writeFirst() {
        ArrayList<String> list = new ArrayList<String>();
        list.add("hello");
        list.add("world");

        FileOutputStream fout;
        ObjectOutputStream out = null;
        try {
            fout = new FileOutputStream("timetracker.data");
            out = new ObjectOutputStream(fout);
            out.writeObject(list);
            out.flush();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                out.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    public void readAfter() {
        ObjectInputStream ois = null;
        try {
            ois = new ObjectInputStream(new FileInputStream("timetracker.data"));
            ArrayList<String> list = (ArrayList<String>) ois.readObject();
            System.out.println(list);
        } catch (ClassNotFoundException | IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

你换成你使用的ArrayList就可以了。试试看。

wojiushiwo945you
毕小宝 可以这么理解。怎么都需要先写入再读的。
4 年多之前 回复
Huxleye
Huxleye 我是在之后才向其中序列化输入内容的 所以说我应该在readObject的时候先判断其返回值是否为null,如果是null的话就可以跳过第一次的取值,进行到下面的序列化输入内容 请问是这个意思么
4 年多之前 回复
Huxleye
Huxleye 我是在之后才向其中序列化输入内容的 所以说我应该在readObject的时候先判断其返回值是否为null,如果是null的话就可以跳过第一次的取值,进行到下面的序列化输入内容 请问是这个意思么
4 年多之前 回复
wojiushiwo945you
毕小宝 回复Huxleye: 那就是根源所在了。对你有帮助就好!祝好!
4 年多之前 回复
Huxleye
Huxleye 非常感谢回答 我应该理解到你的意思了 因为我的程序在开始的时候就要调用ObjectInputStream来调取内容,而这个时候我的文件中可能没有存在内容。
4 年多之前 回复

流读取,每次只能读取指定大小的字节数,这个数你可以自己定义,比如2048,然后你就while,直到读不到数据为止

Huxleye
Huxleye 不可以用readObject将文件的全部内容作为ArrayList读出么 我在存入数据的时候就是writeObject了那个ArrayList进去
4 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
JAVA中ObjectInputStream中将多个Object存入ArrayList中

ArrayList用迭代器存进文件的数据怎么取回到ArrayList中 循环判定是什么 我写了一个总是报 EOF异常

java循环读取mysql并存入java集合里

如果数据库数据过大,用java读取数据库,分页存入集合,每分页一次集合就被调用一次,这个java实现的方式是怎么样的?直接 直接在sql语句上面加个for循环吗?for(){ String sql = "SELECT ID,name, url From websites limit " + (i * 2) + ",2;";......}

Java中使用FTPClient读取ftp文件过程中无法修改读取文件的文件名

使用FTPClient读取ftp上的某个txt文件内容,存到数据库,然后再加读取到的txt文件重命名,在重命名过程失败,代码如下 public void readAndInsert(){ LOGGER.info("开始读取各场景投诉类型并存入数据库"); //ftp配置信息读取 String host = ConfigUtil.getValue("zhzd.ftp.host"); String userName = ConfigUtil.getValue("zhzd.ftp.username"); String password = ConfigUtil.getValue("zhzd.ftp.password"); //ftp连接 FTPClient ftp = new FTPClient(); try { ftp.connect(host); ftp.login(userName,password); } catch (Exception e) { LOGGER.info("投诉工单类型:ftp连接异常..."); e.printStackTrace(); } //ftp文件读取 FTPFile[] files = null; String targetFileName = ""; //目标文件名 try { files = ftp.listFiles(); int length = files.length; int fileNum = 0; //txt文件个数 List<String> fileList = new ArrayList<String>(); //存储所有txt文件名 for(int i=0;i < length ;i++){ if(files[i].getName().contains("txt")){ fileList.add(files[i].getName()); fileNum++; }; } //ftp文件操作-获取目标文件,其他文件放入old文件夹 if(fileNum == 0){ //没有txt文件,不更新 LOGGER.info("投诉工单类型:FTP下没有txt文件..."); ftp.disconnect(); return; }else if(fileNum == 1){ //只有一个txt,不读取,不更新 LOGGER.info("投诉工单类型:FTP下只有一个txt文件,今日数据库不需更新..."); ftp.disconnect(); return; }else{ //两个或者多个,取日期最大的那个 int[] dateArr = new int[fileNum]; for(int i=0;i<fileNum;i++){ dateArr[i] = Integer.parseInt(fileList.get(i).split("_")[3].substring(0, 8)); } Arrays.sort(dateArr); //留下日期最大的文件,其余的都放入old文件夹 /***********************其他没有读取的文件可以重命名(rename)******************************/ for(int i=0;i<fileNum;i++){ if(fileList.get(i).contains(String.valueOf(dateArr[fileNum-1]))){ targetFileName = fileList.get(i); LOGGER.info("投诉工单类型:目标文件为{}...", targetFileName); fileList.remove(i); break; } } //移动文件 Iterator<String> it = fileList.iterator(); String backName = ""; while(it.hasNext()){ backName = it.next(); ftp.rename(backName,"old/"+backName); LOGGER.info("投诉工单类型:文件{}放入old文件夹...",backName); } } } catch (Exception e) { LOGGER.info("投诉工单类型:ftp文件列表读取异常..."); e.printStackTrace(); } //数据库操作 if(!"".equals(targetFileName)){ //删表 dnTimerDao.deleteSendType(); //读文件 InputStreamReader read = null; try { read = new InputStreamReader(ftp.retrieveFileStream(targetFileName),"GBK"); BufferedReader bufferedReader = new BufferedReader(read); String lineTxt = null; String[] str = null; while ((lineTxt = bufferedReader.readLine()) != null) { str = lineTxt.split(""); //存入数据库 if(str.length == 7){ dnTimerDao.insertSendType(str); }else{ throw new IOException("文件内容读取异常!"); } } read.close(); /*******************我用字符流读取的文件重命名失败,我将字符流、 字节流、输入流等都关闭了,也无法重命名*********************/ ftp.rename(targetFileName,"old/"+targetFileName); LOGGER.info("完成各场景投诉类型的读取和存入"); } catch (UnsupportedEncodingException e) { LOGGER.info("投诉工单类型:文件编码异常..."); e.printStackTrace(); } catch (IOException e) { LOGGER.info("投诉工单类型:文件内容的读取异常..."); e.printStackTrace(); } finally { if(read != null){ try { read.close(); } catch (IOException e) { e.printStackTrace(); } } try { ftp.disconnect(); } catch (IOException e) { e.printStackTrace(); } } } } }

通讯录中TXT文件读取问题

``` package in; import java.awt.Container; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.WindowConstants; public class Demo extends JFrame { /* * 界面设计 * */ public Demo(){ Container c = getContentPane(); //定义一个顶级容器c setAlwaysOnTop(true); //窗体置顶 JPanel jp = new JPanel(); //新建JPanel面板--jp JButton button1 = new JButton("新建联系人"); JButton button2 = new JButton("删除联系人"); JButton button3 = new JButton("编辑联系人"); JButton button4 = new JButton("查找联系人"); JButton button5 = new JButton("显示所有联系人"); JButton button6 = new JButton("保存联系人到本地"); JButton button7 = new JButton("读取本地联系人"); jp.setLayout(new GridLayout(3,4,5,5));//新建网格布局管理器(行数,列数,组件间的水平垂直间距) jp.add(button1); jp.add(button2); jp.add(button3); jp.add(button4); jp.add(button5); jp.add(button6); jp.add(button7); c.add(jp);//将JPanel面板jp添加到顶级容器c中 setSize(600,150); setTitle("*通 讯 录 管 理 系 统*"); setVisible(true); setResizable(false);//窗体大小由程序员决定,用户不能自由改变大小 setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); /* *按键响应 * * */ button1.addActionListener(new ActionListener(){//添加功能实现 public void actionPerformed(ActionEvent arg0){ Infro.addFunction(); } }); button2.addActionListener(new ActionListener(){//删除功能实现 public void actionPerformed(ActionEvent arg0){ Infro.deleteFunction(); } }); button3.addActionListener(new ActionListener(){//修改功能实现 public void actionPerformed(ActionEvent arg0){ Infro.reditFunction(); } }); button4.addActionListener(new ActionListener(){//查询功能实现 public void actionPerformed(ActionEvent arg0){ try { Infro.searchFunction(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); button5.addActionListener(new ActionListener(){//显示功能实现 public void actionPerformed(ActionEvent arg0){ Infro.showFunction(); } }); button6.addActionListener(new ActionListener(){//保存功能实现 public void actionPerformed(ActionEvent arg0){ try { Infro.writeFunction(); } catch (IOException e) { e.printStackTrace(); } } }); button7.addActionListener(new ActionListener(){//读取功能实现 public void actionPerformed(ActionEvent arg0){ try { Infro.readFunction(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } public static void main(String[] args) { // TODO Auto-generated method stub new Demo(); Infro a = new Infro("", "", "", "", "", ""); } } package in; import java.applet.Applet; import java.awt.Graphics; import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.StringWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import javax.swing.JPanel; class Infro { public String Name; public String Sex; public String Unit; public String Homephone; public String Telephone; public String E_mail; static int index = 0; static ArrayList<Infro> list = new ArrayList(); static int len = list.size(); //构造函数 public Infro(String Name,String Sex,String Unit,String Homephone,String Telephone,String E_mail){ this.Name = Name; this.Sex = Sex; this.Unit = Unit; this.Homephone = Homephone; this.Telephone = Telephone; this.E_mail = E_mail; } public String toString(){ return "姓名:"+Name+"\t性别:"+Sex+"\t单位:"+Unit+"\t住宅电话:"+Homephone +"\t移动电话:"+Telephone+"\tE_mail:"+E_mail; } /* * 添加功能 * */ public static void addFunction(){//添加功能 Infro infro = new Infro("","","","","",""); System.out.println("请输入添加的数据:"); Scanner in = new Scanner(System.in); System.out.println("输入姓名:"); infro.Name = in.next(); System.out.println("输入性别:"); infro.Sex = in.next(); System.out.println("输入单位:"); infro.Unit = in.next(); System.out.println("输入住宅电话:"); infro.Homephone = in.next(); System. out.println("输入移动电话:"); infro.Telephone = in.next(); System.out.println("输入E_mail:"); infro.E_mail = in.next(); list.add(index,infro); index++; if(list.isEmpty()){ System.out.println("数据添加失败啦"); }else{ System.out.println("数据添加成功啦"); len++;//list集合长度加一 // System.out.println(list.get(0).toString()); } System.out.println("是否继续添加?1.是 2.否"); Scanner e=new Scanner(System.in); int e1=e.nextInt(); if(e1==1){ Infro.addFunction(); }else{ return; } } /* * 删除功能 * */ public static void deleteFunction(){ System.out.println("输入要删除的联系人的姓名"); Scanner in_2 = new Scanner(System.in); String d1 = in_2.nextLine(); java.util.Iterator<Infro> it = list.iterator(); while (it.hasNext()){ Infro infro = it.next(); if (infro.Name.equals(d1)){ it.remove(); --index;//一定要加这个,否则当做了删除操作再做添加操作的时候会出现异常(类似于指针,栈) System.out.println("删除完毕"+"此时通讯录记录条数为:" + --len); } } System.out.println("是否继续删除?1.是 2.否"); Scanner e=new Scanner(System.in); int e1=e.nextInt(); if(e1==1){ Infro.deleteFunction(); }else{ return; } } /* * 修改功能 * */ public static void reditFunction(){ System.out.println("输入要修改的通讯录的姓名"); Scanner in_r = new Scanner(System.in); String r1 = in_r.nextLine(); for(int a = 0; a < len;a++){ if(r1.equals(list.get(a).Name)){ System.out.println("输入修改后的性别:"); String Sex_1 = in_r.next(); list.get(a).Sex = Sex_1; System.out.println("输入修改后的单位:"); String Unit_1 = in_r.next(); list.get(a).Unit = Unit_1; System.out.println("输入修改后的住宅电话:"); String Homephone_1 = in_r.next(); list.get(a).Homephone = Homephone_1; System.out.println("输入修改后的移动电话:"); String Telephone_1 = in_r.next(); list.get(a).Telephone = Telephone_1; System.out.println("输入修改后的E_mail:"); String E_mail_1 = in_r.next(); list.get(a).E_mail = E_mail_1; System.out.println("数据修改完毕"); } } System.out.println("是否继续修改?1.是 2.否"); Scanner e=new Scanner(System.in); int e1=e.nextInt(); if(e1==1){ Infro.reditFunction(); }else{ return; } } /* * 查询功能 * */ public static void searchFunction() throws Exception{//查询功能 System.out.println("请选择查询方式: "); System.out.println("1.姓名 2.性别 3.单位 4.住宅电话 5.移动电话 6.E_mail "); Scanner in_0=new Scanner(System.in); int s0=in_0.nextInt(); if(s0==1){ System.out.println("请输入要查询的姓名:"); Scanner in_1 = new Scanner(System.in); String s1=in_1.nextLine(); for(int a= 0; a<len;a++){//切记,,这里不能用a<=list.size(),否则会数组越界异常 if(s1.equals(list.get(a).Name)){ System.out.println(list.get(a).toString()); } } } else if(s0==2){ System.out.println("请输入要查询的性别:"); Scanner in_2 = new Scanner(System.in); String s2=in_2.nextLine(); for(int a= 0; a<len;a++){//切记,,这里不能用a<=list.size(),否则会数组越界异常 if(s2.equals(list.get(a).Sex)){ System.out.println(list.get(a).toString()); } } } else if(s0==3){ System.out.println("请输入要查询的单位:"); Scanner in_3 = new Scanner(System.in); String s3=in_3.nextLine(); for(int a= 0; a<len;a++){//切记,,这里不能用a<=list.size(),否则会数组越界异常 if(s3.equals(list.get(a).Unit)){ System.out.println(list.get(a).toString()); } } } if(s0==4){ System.out.println("请输入要查询的住宅电话:"); Scanner in_4 = new Scanner(System.in); String s4=in_4.nextLine(); for(int a= 0; a<len;a++){//切记,,这里不能用a<=list.size(),否则会数组越界异常 if(s4.equals(list.get(a).Homephone)){ System.out.println(list.get(a).toString()); } } } else if(s0==5){ System.out.println("请输入要查询的移动电话:"); Scanner in_5 = new Scanner(System.in); String s5=in_5.nextLine(); for(int a= 0; a<len;a++){//切记,,这里不能用a<=list.size(),否则会数组越界异常 if(s5.equals(list.get(a).Telephone)){ System.out.println(list.get(a).toString()); } } } else if(s0==6){ System.out.println("请输入要查询的E_mail:"); Scanner in_6 = new Scanner(System.in); String s6=in_6.nextLine(); for(int a= 0; a<len;a++){//切记,,这里不能用a<=list.size(),否则会数组越界异常 if(s6.equals(list.get(a).E_mail)){ System.out.println(list.get(a).toString()); } } } } /* * 显示功能 * */ public static void showFunction(){ for(int i = 0 ;i<len;i++){ System.out.println(list.get(i).toString()); } } /* * 保存功能 * */ public static void writeFunction() throws IOException{ FileWriter writer = new FileWriter("通讯录管理.txt"); for(int i = 0 ;i<len;i++){ String []strwriter = new String[len]; strwriter[i]=list.get(i).toString(); writer.write(strwriter[i]); writer.write("\r\n"); System.out.println("成功写入一行数据到 通讯录管理.txt 中"); } writer.close();//关闭写入流,释放资源 } /* * 读取功能 * */ public static void readFunction() throws IOException{ FileReader reader = new FileReader("通讯录管理.txt"); BufferedReader br = new BufferedReader(reader); String str; while((str = br.readLine()) != null){//每次读取一行文本,判断是否到达文件尾 System.out.println(str); } br.close(); } } ``` 课程设计中遇到了问题… 在运行时输入,可以查询,编辑等操作。可是保存到本地后退出运行,第二次再运行时读取本地联系人,就没办法执行查询操作了。我改了好久还是不行,请各位哥哥姐姐帮忙看一下,拜托~因为还没有学数据库,只能用文件了。 超过20个分屏显示就不要了,因为貌似java没有分屏显示……其他的功能,按姓名排序也希望你们能给些思路,谢谢谢谢 这是题目: 3. 以本班同学的具体数据为背景,设计一个本班同学通讯录(3人) 通讯录要求存储姓名、性别、单位、住宅电话、移动电话、E-mail地址等内容。系统功能要求如下: (1)通讯录记录按姓名排序存放,显示时每屏不超过20个记录,超过时分屏显示。 (2)增加某人的通讯录。 (3)修改某人的通讯录。 (4)删除某人的通讯录。 (5)按多种方式查询符合条件的信息。

如何把ArrayList里的数据逐条显示到TextView

ArrayList〈Word〉 wordlist。里面有10条数据,每条数据包括english,mean。怎样把里面的数据显示在TextView,在显示textview的活动里,点击“下一个”按钮,textview就消失wordlist里的下一个数据。

如何在一个方法内将对象存入list中,放入session,再次执行该方法如何将新的对象继续存入?

1.在执行方法SavaQuestion,定义一个list对象 questionNaireQuestionslist 2.再将questionNaireQuestion对象放入这个list对象questionNaireQuestionslist中 3.将list对象questionNaireQuestionslist保存入session中,将questionNaireQuestion保存入session中 4.如何再次执行这个方法SavaQuestion,将新的questionNaireQuesion对象存入list中 5.我每次将新的questionNaireQuesion对象存入list中时都会覆盖原有的,list对象questionNaireQuestionslist永远只有一个元素 ``` public String saveQuestion(HttpServletRequest request) { List<QuestionNaireQuestion> questionNaireQuestionslist = new ArrayList<QuestionNaireQuestion>(); QuestionNaireQuestion questionNaireQuestion = new QuestionNaireQuestion(); //...... questionNaireQuestionslist.add(questionNaireQuestion); //将List对象questionNaireQuestionslist存入session中 request.getSession().setAttribute("questionNaireQuestionslist", questionNaireQuestionslist); //将questionNaireQuestion对象存入session中 request.getSession().setAttribute("questionNaireQuestion", questionNaireQuestion); ```

java读取xml,将读到的数据存放到对象中,再按照一定条件写入xml,从而生成动态菜单

做eclipse插件开发,菜单项的配置是在plugin.xml中是写死的,现在想做成动态菜单的形式。中间写一个类,这个类可以读取一个xml配置文件,然后可以有一些方法把提取过的数据和plugin.xml联系起来,通过这个类来动态的配置eclipse的菜单。我的想法是把读到的xml文件的内容封装到java的对象中,返回值是一个集合类型,然后我就不知道怎么做了。 图片是展示效果: ![图片说明](https://img-ask.csdn.net/upload/201609/01/1472719954_312637.png) ``` 下面是我们找的一些相关资源: [](http://dom4j.sourceforge.net/dom4j-1.6.1/guide.html "") 这是我自己写的demo: package testforxybc; public class UserInfo { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } private String password; } package testforxybc; import java.beans.XMLDecoder; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class UserInfoController { public static void main(String args[]) { List<UserInfo> objList = null; try { objList = UserInfoController.objectXMLDecoder("outxml.xml"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } for (UserInfo userInfo : objList) { System.out.println(userInfo.getName()); System.out.println(userInfo.getPassword()); } } public static List<UserInfo> objectXMLDecoder(String objSource) throws FileNotFoundException,IOException,Exception { List<UserInfo> objList = new ArrayList<UserInfo>(); File fin = new File(objSource); FileInputStream fis = new FileInputStream(fin); XMLDecoder decoder = new XMLDecoder(fis); Object obj = null; try { while( (obj = decoder.readObject()) != null) { objList.add((UserInfo) obj); } } catch (Exception e) { // TODO Auto-generated catch block } fis.close(); decoder.close(); return objList; } } <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> <plugin> <extension point="org.eclipse.ui.commands"> <category name="Inoherb Category" id="com.uds.inoherb.commands.category"> </category> <command name="法规标准库" categoryId="com.uds.inoherb.commands.category" id="com.uds.inoherb.commands.regulatoryStandards"> </command> <command name="产品标准" categoryId="com.uds.inoherb.commands.category" id="com.uds.inoherb.commands.productStandard"> </command> <command name="禁限用清单" categoryId="com.uds.inoherb.commands.category" id="com.uds.inoherb.commands.prohibitedList"> </command> <command name="全成分" categoryId="com.uds.inoherb.commands.category" id="com.uds.inoherb.commands.fullComposition"> </command> <command name="原料库" categoryId="com.uds.inoherb.commands.category" id="com.uds.inoherb.commands.rawMaterial"> </command> <command name="油脂类" categoryId="com.uds.inoherb.commands.category" id="com.uds.inoherb.commands.fadAndOil"> </command> <command name="乳化剂类" categoryId="com.uds.inoherb.commands.category" id="com.uds.inoherb.commands.emulsifier"> </command> <command name="香精类" categoryId="com.uds.inoherb.commands.category" id="com.uds.inoherb.commands.parfum"> </command> <command name="活性物类" categoryId="com.uds.inoherb.commands.category" id="com.uds.inoherb.commands.actives"> </command> </extension> <extension point="org.eclipse.ui.handlers"> <handler commandId="com.uds.inoherb.commands.regulatoryStandards" class="com.uds.inoherb.handlers.SampleHandler"> </handler> <handler commandId="com.uds.inoherb.commands.rawMaterial" class="com.uds.inoherb.handlers.SampleHandler"> </handler> <handler commandId="com.uds.inoherb.commands.productStandard" class="com.uds.inoherb.handlers.SampleHandler"> </handler> <handler commandId="com.uds.inoherb.commands.fadAndOil" class="com.uds.inoherb.handlers.SampleHandler"> </handler> </extension> <extension point="org.eclipse.ui.bindings"> <key commandId="com.uds.inoherb.commands.sampleCommand" contextId="org.eclipse.ui.contexts.window" sequence="M1+6" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"> </key> </extension> <extension point="org.eclipse.ui.menus"> <menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions"> <menu label="企业电子数据库" id="com.uds.inoherb.menus.sampleMenu"> <menu label="法规标准库" id="com.uds.inoherb.menus.sampleMenu2"> <command commandId="com.uds.inoherb.commands.productStandard" id="com.uds.inoherb.menus.productStandard"> </command> <command commandId="com.uds.inoherb.commands.prohibitedList" id="com.uds.inoherb.menus.prohibitedList"> </command> <command commandId="com.uds.inoherb.commands.fullComposition" id="com.uds.inoherb.menus.fullComposition"> </command> </menu> <menu label="原料库" id="com.uds.inoherb.menus.sampleMenu3"> <command commandId="com.uds.inoherb.commands.fadAndOil" id="com.uds.inoherb.menus.fadAndOil"> </command> <command commandId="com.uds.inoherb.commands.emulsifier" id="com.uds.inoherb.menus.emulsifier"> </command> <command commandId="com.uds.inoherb.commands.parfum" id="com.uds.inoherb.menus.parfum"> </command> <command commandId="com.uds.inoherb.commands.actives" id="com.uds.inoherb.menus.actives"> </command> </menu> </menu> </menuContribution> </extension> </plugin> ```

Arraylist集合类里的数据想提取出来显示到Textview中,但程序运行奔溃,求大神解答?

package com.example.http; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.widget.TextView; import java.util.ArrayList; import java.util.Random; /* 题目: 用一个大集合存入20个随机数,然后筛选其中的偶数,放入小集合中 要求使用自定义的方法来实现筛选 分析: 1.创建一个大集合,用来存储int数值:<integer> 2.获取随机数要使用Random 的nextint() 3.循环20次,把随机数放入大集合,for循环,add方法 4.定义一个方法,来进行筛选 筛选:根据大集合,筛选符合要求的元素,得到小集合 定义方法的三要素 返回值类型,方法名称,参数列表 */ public class arraylist extends AppCompatActivity { private TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_arraylist); textView=(TextView)findViewById(R.id.arraytext); //定义一个大集合 ArrayList<Integer> biglist=new ArrayList<>(); Random random=new Random(); for(int i=0;i<20;i++){ //随机产生20个数字 int num=random.nextInt(); //如果想让数字在一定范围 //int num=random.nextint(100)+1;这是产生0到100之间的随机数 //把产生的随机数添加到biglist集合中 biglist.add(num); } ArrayList<Integer> small=getsmalllist(biglist); for(int j=0;j<small.size();j++){ textView.setText(small.get(j)); } } //接下来是写一个小集合方法来存储从大集合获得的偶数 public static ArrayList<Integer> getsmalllist(ArrayList<Integer> biglist){ //首先创建一个小集合 ArrayList<Integer> smalllist=new ArrayList<>(); //然后把大集合里的数据全取出来,进行判断 for (int i = 0; i < biglist.size(); i++) { int num=biglist.get(i); if(num%2==0){ smalllist.add(num); } } return smalllist; } }

关于Redis数据库的java代码多线程读写性能问题,希望可以帮忙看看、、、

渣渣一枚、、由于项目关系,需要用到内存数据库来存key-value所以就开始研究redis这个数据库。现在已经把redis放在了CentOS的测试服务器上,然后通过网上的资料写了链接代码! 测试用了100个线程,每个线程插入10000条数据,结果竟然花了**200s**, 同事用memcached测试同样的数据只要了**20s** 而在linux中用redis自带的redis-benchmark查询性能 结果如下: ``` ====== PING_INLINE ====== 100000 requests completed in 0.72 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 139082.06 requests per second ====== PING_BULK ====== 100000 requests completed in 0.73 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 136798.91 requests per second ====== SET ====== 100000 requests completed in 0.72 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 139275.77 requests per second ====== GET ====== 100000 requests completed in 0.73 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 137931.03 requests per second ====== INCR ====== 100000 requests completed in 0.71 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 141643.06 requests per second ====== LPUSH ====== 100000 requests completed in 0.71 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 141442.72 requests per second ====== LPOP ====== 100000 requests completed in 0.72 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 139664.80 requests per second ====== SADD ====== 100000 requests completed in 0.71 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 140845.08 requests per second ====== SPOP ====== 100000 requests completed in 0.71 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 140252.45 requests per second ====== LPUSH (needed to benchmark LRANGE) ====== 100000 requests completed in 0.71 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 141043.72 requests per second ====== LRANGE_100 (first 100 elements) ====== 100000 requests completed in 1.77 seconds 50 parallel clients 3 bytes payload keep alive: 1 100.00% <= 0 milliseconds 56433.41 requests per second ====== LRANGE_300 (first 300 elements) ====== 100000 requests completed in 4.78 seconds 50 parallel clients 3 bytes payload keep alive: 1 1.20% <= 1 milliseconds 99.60% <= 2 milliseconds 99.93% <= 3 milliseconds 100.00% <= 3 milliseconds 20938.02 requests per second ====== LRANGE_500 (first 450 elements) ====== 100000 requests completed in 6.78 seconds 50 parallel clients 3 bytes payload keep alive: 1 0.02% <= 1 milliseconds 99.75% <= 2 milliseconds 99.96% <= 3 milliseconds 99.99% <= 4 milliseconds 100.00% <= 4 milliseconds 14749.26 requests per second ====== LRANGE_600 (first 600 elements) ====== 100000 requests completed in 8.76 seconds 50 parallel clients 3 bytes payload keep alive: 1 0.02% <= 1 milliseconds 7.64% <= 2 milliseconds 99.67% <= 3 milliseconds 99.75% <= 4 milliseconds 99.83% <= 5 milliseconds 99.90% <= 6 milliseconds 99.96% <= 7 milliseconds 100.00% <= 8 milliseconds 100.00% <= 8 milliseconds 11416.83 requests per second ====== MSET (10 keys) ====== 100000 requests completed in 1.13 seconds 50 parallel clients 3 bytes payload keep alive: 1 99.98% <= 1 milliseconds 100.00% <= 1 milliseconds 88573.96 requests per second ``` 显示出来的set、get什么的都是10W/S的请求, 所以我的代码应该有问题,不然也不会出现200S的结果,应该是在多线程哪里出了问题,希望可以帮我看看、、 新人、、木有C币,希望大家帮我看看! ``` public class RedisClient { private Jedis jedis;//非切片额客户端连接 private JedisPool jedisPool;//非切片连接池 private ShardedJedis shardedJedis;//切片额客户端连接 private ShardedJedisPool shardedJedisPool;//切片连接池 private static long START_TIME; private static int TOTAL_COUNT =100; private static int END_COUNT; private static final int COUNT = 10000; public RedisClient() { initialPool(); initialShardedPool(); shardedJedis = shardedJedisPool.getResource(); jedis = jedisPool.getResource(); } /** * 初始化非切片池(非分布式) */ private void initialPool() { // 池基本配置 JedisPoolConfig config = new JedisPoolConfig(); config.setMaxTotal(128); config.setMinIdle(10); config.setMaxIdle(128); config.setMaxWaitMillis(30000l); config.setTestOnBorrow(false); jedisPool = new JedisPool(config, "192.168.1.110", 6379, 0); } /** * 初始化切片池(分布池) */ private void initialShardedPool() { // 池基本配置 JedisPoolConfig config = new JedisPoolConfig(); config.setMaxTotal(128); config.setMinIdle(10); config.setMaxIdle(128); config.setMaxWaitMillis(30000l); config.setTestOnBorrow(false); // slave链接 List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(); shards.add(new JedisShardInfo("192.168.1.110", 6379, 0)); // 构造池 shardedJedisPool = new ShardedJedisPool(config, shards); } public void show() { HashOperate(); } private void HashOperate() { System.out.println("======================hash=========================="); //清空数据 System.out.println(jedis.flushDB()); System.out.println("=============增============="); Thread[] threads = new Thread[TOTAL_COUNT]; for (int i = 0; i < TOTAL_COUNT; i++) { threads[i] = new TTestThread(i * COUNT, COUNT); } START_TIME = System.currentTimeMillis(); for (int i = 0; i < TOTAL_COUNT; ++i) { threads[i].start(); } } private class TTestThread extends Thread { private int mOffset; private int mCount; private Transaction tx; public TTestThread(int offset, int count) { mOffset = offset; mCount = count; } @Override public void run() { super.run(); ShardedJedis shardedJedis = shardedJedisPool.getResource(); try { for (int i = mOffset; i < mCount + mOffset; ++i) { shardedJedis.hset("hashs", "key" + i, String.valueOf(i)); } } finally { shardedJedisPool.returnResource(shardedJedis); } synchronized (TTestThread.class) { ++END_COUNT; if (END_COUNT == TOTAL_COUNT) { System.out.println("time is " + (System.currentTimeMillis() - START_TIME)); } } } } } ```

关于java静态变量的存储位置

网上有很多关于类变量存储位置的文章,比如http://gao-xianglong.iteye.com/blog/2152345 说明静态变量是存储在方法区中,但是本人随便写了个例子如下: public static Object o = new Object[999999999]; public static void main(String[] args) { } 运行报出java.lang.OutOfMemoryError: Java heap space说明是堆溢出了,难道静态变量又存储在堆中了? 关于这块很不解,求解释

我要怎么得到arraylist里面的数据

![图片说明](https://img-ask.csdn.net/upload/201508/24/1440378693_426906.png) ![图片说明](https://img-ask.csdn.net/upload/201508/24/1440378743_855576.png)

JAVA输出流中的数据怎么存到集合中

创建一个学生类 使用ArrayList赋值属性然后通过InputStream存到一个txt文档里,输出流的时候怎样才能吧数据还原成一个类存到集合里面遍历查找呢

Java从数据库多个表中获取信息,添加到JComboBox中要怎么做?

java中一个功能,需要在多个选修课表中,根据学号获取各个选修课表中本学号所选的科目,并添加到JComboBox中。形成一个下拉列表,要怎么做?

Java操作MongoDB写入,丢失数据

Java 代码如下: ``` public void doAfterSave(String date_ymd) { try { ArrayList<DBObject> insertList = getArrayList(concurrentResultMap.values()); if (insertList.size() == 0) return; utilsService.getMongoPersist().getMongoCollection(MongoPersist.RtSellerRegion_h).insert(insertList); } finally { concurrentResultMap.clear(); } } ``` 当Mongo中collection为空的时候,插入正常,可是当再次执行这个写入的动作后,mongo中有一个region_id字段出现大量丢失现象。 代码中的insertlist我在debug的时候,都在控制台打印出来了,在写入前数据是完整的,但是写入后就会出现丢失现象。, 我尝试改变数据类型改为Long,Double,String,添加数据库索引,甚至直接删除了数据库集合。 可是现在还是这样,求助啊。

Java语言高分悬赏:怎么读取一个arrylist表中所有的条目,并且输出一个条目,输出这个条目是否出现在列表上

Java语言高分悬赏:怎么读取一个arrylist表中所有的条目,并且输出一个条目,输出这个条目是否出现在列表上 Java语言高分悬赏:怎么读取一个arrylist表中所有的条目,并且输出一个条目,输出这个条目是否出现在列表上

获取CSV文件(考勤信息)内容放入集合,怎么获取集合中的每人每天的最早和最晚时间。求大神解决。

> List<XXattendance> dkinfos = new ArrayList<XXattendance>();//保存读取csv得到的数据 Map<String, List<XXattendance>> map = new HashMap<String, List<XXattendance>>();//分组统计的map集合 public void generic(){ String sbip = null; List<XXattendance> mapDkinfos = new ArrayList<XXattendance>();//map集合中每组ip的对应的对象集合 BufferedReader reader = null; //读写csv数据到list(dkinfos)集合中 try { reader = new BufferedReader(new FileReader("C:\\Users\\Lollipop\\Desktop\\考勤信息.CSV"));//换成你的文件名 String line = null; while((line=reader.readLine())!=null){ String data[] = line.split(",");//CSV格式文件为逗号分隔符文件,这里根据逗号切分 XXattendance dkinfo = new XXattendance(); dkinfo.setName(data[1]); dkinfo.setN_id(data[2]); dkinfo.setDate(data[3]); dkinfos.add(dkinfo); // System.out.println(data[0]+","+data[1]); // System.out.println(dkinfo.getName()+dkinfo.getN_id()+dkinfo.getDate()); } //遍历集合,将数据分组存入map集合 for(XXattendance dkinfo : dkinfos){ sbip = dkinfo.getN_id(); sbip = dkinfo.getDate(); mapDkinfos = map.get(sbip);//获取对应sbip的集合,第一次获取时为空 if(mapDkinfos == null){//这里如果不进行为空判断,会报空指针异常 mapDkinfos = new ArrayList<XXattendance>(); } mapDkinfos.add(dkinfo);//将新添加的对象加入到对应的sbip的对象集合 map.put(sbip, mapDkinfos); //将每次新添加对象后的对象集合存入对应map中 } Iterator<XXattendance> iter = dkinfos.iterator(); //遍历map集合 for (Map.Entry<String, List<XXattendance>> entry : map.entrySet()) { // System.out.println("考勤号: " + entry.getKey() + "打卡次数:" + entry.getValue().size()); } } catch (Exception e) { e.printStackTrace(); } finally{ try { reader.close(); dkinfos.clear(); map.clear(); mapDkinfos.clear(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } SCV数据: "部门","姓名","考勤号码","日期时间","机器号","编号","比对方式","卡号" ,"王","005","2017/5/2 9:06:13","1","","指纹","" ,"王","005","2017/5/2 10:35:04","1","","指纹","" ,"王","005","2017/5/2 19:21:28","1","","指纹","" ,"王","005","2017/5/2 19:22:43","1","","指纹","" ,"王","005","2017/5/3 13:58:49","1","","密码","" ,"王","005","2017/5/3 14:01:46","1","","密码","" ,"王","005","2017/5/3 14:10:11","1","","密码","" ,"王","005","2017/5/3 16:58:06","1","","指纹","" ,"王","005","2017/5/4 8:57:29","1","","指纹","" ,"王","005","2017/5/4 9:53:30","1","","密码","" ,"王","005","2017/5/4 11:03:16","1","","指纹","" ,"王","005","2017/5/4 12:29:13","1","","指纹","" ,"王","005","2017/5/4 13:58:32","1","","指纹","" ,"王","005","2017/5/4 14:24:46","1","","指纹","" ,"王","005","2017/5/4 14:49:02","1","","指纹","" ,"王","005","2017/5/4 16:22:15","1","","指纹","" ,"王","005","2017/5/4 18:10:31","1","","指纹","" ,"王","005","2017/5/5 8:53:24","1","","指纹","" ,"王","005","2017/5/5 9:21:41","1","","指纹","" ,"王","005","2017/5/5 11:30:13","1","","密码","" ,"王","005","2017/5/5 12:59:00","1","","指纹","" ,"王","005","2017/5/5 13:01:05","1","","密码","" ,"王","005","2017/5/5 13:48:33","1","","指纹","" ,"王","005","2017/5/5 15:38:59","1","","指纹","" ,"王","005","2017/5/5 18:03:22","1","","指纹","" ,"王","005","2017/5/8 10:11:59","1","","指纹","" ,"王","005","2017/5/8 10:36:55","1","","指纹","" ,"王","005","2017/5/8 11:34:26","1","","指纹","" ,"王","005","2017/5/8 11:46:22","1","","指纹","" ,"王","005","2017/5/8 13:01:05","1","","指纹","" ,"王","005","2017/5/8 13:42:16","1","","指纹","" ,"王","005","2017/5/8 15:41:08","1","","指纹","" ,"王","005","2017/5/8 15:44:01","1","","指纹","" ,"王","005","2017/5/8 18:06:13","1","","指纹","" ,"王","005","2017/5/8 18:10:54","1","","指纹","" ,"王","005","2017/5/9 9:02:09","1","","指纹","" ,"王","005","2017/5/9 10:45:04","1","","指纹","" ,"王","005","2017/5/9 15:54:49","1","","指纹","" ,"王","005","2017/5/9 16:21:58","1","","指纹","" ,"王","005","2017/5/12 8:43:06","1","","指纹","" ,"王","005","2017/5/15 8:58:31","1","","指纹","" ,"王","005","2017/5/15 9:07:21","1","","指纹","" ,"王","005","2017/5/15 13:47:58","1","","指纹","" ,"李","007","2017/5/3 18:15:51","1","","指纹","" ,"李","007","2017/5/4 8:46:05","1","","指纹","" ,"李","007","2017/5/4 8:59:47","1","","指纹","" ,"李","007","2017/5/4 11:13:44","1","","指纹","" ,"李","007","2017/5/4 12:08:21","1","","指纹","" ,"李","007","2017/5/4 13:27:26","1","","指纹","" ,"李","007","2017/5/4 15:32:24","1","","指纹","" ,"李","007","2017/5/4 16:50:40","1","","指纹","" ,"李","007","2017/5/4 18:10:17","1","","指纹","" ,"李","007","2017/5/5 8:45:16","1","","指纹","" ,"李","007","2017/5/5 8:55:33","1","","指纹","" ,"李","007","2017/5/5 8:56:18","1","","指纹","" ,"李","007","2017/5/5 16:38:41","1","","指纹","" ,"李","007","2017/5/5 18:03:41","1","","指纹","" ,"李","007","2017/5/8 8:49:04","1","","指纹","" ,"李","007","2017/5/8 8:50:14","1","","指纹","" ,"李","007","2017/5/8 10:03:45","1","","指纹","" ,"李","007","2017/5/8 12:18:39","1","","指纹","" ,"李","007","2017/5/8 12:27:55","1","","指纹","" ,"李","007","2017/5/8 14:02:19","1","","指纹","" ,"李","007","2017/5/8 14:33:45","1","","指纹","" ,"李","007","2017/5/8 18:06:19","1","","指纹","" ,"李","007","2017/5/8 18:18:26","1","","指纹","" ,"李","007","2017/5/9 8:48:39","1","","指纹","" ,"李","007","2017/5/9 8:49:53","1","","指纹","" ,"李","007","2017/5/9 13:33:35","1","","指纹","" ,"李","007","2017/5/9 15:00:58","1","","指纹","" ,"李","007","2017/5/9 17:40:10","1","","指纹","" ,"李","007","2017/5/9 18:07:28","1","","指纹","" ,"李","007","2017/5/12 8:55:34","1","","指纹","" ,"李","007","2017/5/12 8:58:09","1","","指纹","" ,"李","007","2017/5/12 11:11:20","1","","指纹","" ,"李","007","2017/5/12 15:09:12","1","","指纹","" ,"李","007","2017/5/12 16:27:09","1","","指纹","" ,"李","007","2017/5/12 17:56:23","1","","指纹","" ,"李","007","2017/5/12 18:10:22","1","","指纹","" ,"李","007","2017/5/15 8:50:59","1","","指纹","" ,"李","007","2017/5/15 9:06:47","1","","指纹","" ,"张","008","2017/5/2 9:13:02","1","","指纹","" ,"张","008","2017/5/2 16:28:27","1","","指纹","" ,"张","008","2017/5/2 17:38:45","1","","指纹","" ,"张","008","2017/5/3 9:04:40","1","","指纹","" ,"张","008","2017/5/3 9:08:44","1","","指纹","" ,"张","008","2017/5/3 13:56:29","1","","指纹","" ,"张","008","2017/5/4 10:40:16","1","","指纹","" ,"张","008","2017/5/4 11:56:22","1","","指纹","" ,"张","008","2017/5/4 13:17:10","1","","指纹","" ,"张","008","2017/5/4 13:34:48","1","","密码","" ,"张","008","2017/5/4 15:34:28","1","","密码","" ,"张","008","2017/5/4 15:49:44","1","","指纹","" ,"张","008","2017/5/5 10:58:58","1","","指纹","" ,"张","008","2017/5/5 12:34:57","1","","密码","" ,"张","008","2017/5/5 16:45:05","1","","指纹","" ,"张","008","2017/5/8 10:17:23","1","","指纹","" ,"张","008","2017/5/8 10:23:07","1","","指纹","" ,"张","008","2017/5/8 12:10:50","1","","指纹","" ,"张","008","2017/5/8 15:10:49","1","","指纹","" ,"张","008","2017/5/9 10:13:12","1","","指纹","" ,"张","008","2017/5/9 11:51:06","1","","指纹","" ,"张","008","2017/5/9 12:19:36","1","","指纹","" ,"张","008","2017/5/9 13:30:50","1","","指纹","" ,"张","008","2017/5/11 10:13:07","1","","指纹","" ,"张","008","2017/5/11 11:26:39","1","","指纹","" ,"张","008","2017/5/11 12:04:37","1","","指纹","" ,"张","008","2017/5/11 13:56:43","1","","指纹","" ,"张","008","2017/5/15 9:19:06","1","","指纹","" ,"张","008","2017/5/15 12:07:44","1","","指纹","" ,"张","008","2017/5/15 13:14:25","1","","密码","" ,"于","009","2017/5/2 9:10:01","1","","指纹","" ,"于","009","2017/5/2 17:58:15","1","","指纹","" ,"于","009","2017/5/3 9:07:14","1","","指纹","" ,"于","009","2017/5/3 18:15:26","1","","指纹","" ,"于","009","2017/5/4 8:58:18","1","","指纹","" ,"于","009","2017/5/4 9:51:00","1","","指纹","" ,"于","009","2017/5/4 13:56:46","1","","指纹","" ,"于","009","2017/5/4 14:47:43","1","","指纹","" ,"于","009","2017/5/4 15:51:32","1","","指纹","" ,"于","009","2017/5/4 16:49:36","1","","指纹","" ,"于","009","2017/5/4 18:10:11","1","","指纹","" ,"于","009","2017/5/5 8:46:30","1","","指纹","" ,"于","009","2017/5/5 8:59:37","1","","指纹","" ,"于","009","2017/5/5 9:25:21","1","","指纹","" ,"于","009","2017/5/5 9:54:00","1","","指纹","" ,"于","009","2017/5/5 10:31:46","1","","指纹","" ,"于","009","2017/5/5 13:38:04","1","","指纹","" ,"于","009","2017/5/5 14:53:26","1","","指纹","" ,"于","009","2017/5/5 16:39:31","1","","指纹","" ,"于","009","2017/5/5 17:49:45","1","","指纹","" ,"于","009","2017/5/5 18:03:37","1","","指纹","" ,"于","009","2017/5/8 8:48:25","1","","指纹","" ,"于","009","2017/5/8 9:48:53","1","","指纹","" ,"于","009","2017/5/8 12:42:48","1","","指纹","" ,"于","009","2017/5/8 14:13:43","1","","指纹","" ,"于","009","2017/5/8 16:10:01","1","","指纹","" ,"于","009","2017/5/8 16:57:31","1","","指纹","" ,"于","009","2017/5/8 18:26:59","1","","指纹","" ,"于","009","2017/5/8 18:57:02","1","","指纹","" ,"于","009","2017/5/8 18:58:06","1","","指纹","" ,"于","009","2017/5/9 8:42:26","1","","指纹","" ,"于","009","2017/5/9 9:34:07","1","","指纹","" ,"于","009","2017/5/9 11:46:12","1","","指纹","" ,"于","009","2017/5/9 13:47:02","1","","指纹","" ,"于","009","2017/5/9 17:25:17","1","","指纹","" ,"于","009","2017/5/9 18:05:02","1","","指纹","" ,"于","009","2017/5/10 8:46:50","1","","指纹","" ,"于","009","2017/5/10 10:14:49","1","","指纹","" ,"于","009","2017/5/10 10:37:15","1","","指纹","" ,"于","009","2017/5/10 11:35:05","1","","指纹","" ,"于","009","2017/5/10 13:34:00","1","","指纹","" ,"于","009","2017/5/10 15:28:08","1","","指纹","" ,"于","009","2017/5/10 16:13:17","1","","指纹","" ,"于","009","2017/5/10 18:11:05","1","","指纹","" ,"于","009","2017/5/11 8:50:41","1","","指纹","" ,"于","009","2017/5/11 9:57:43","1","","指纹","" ,"于","009","2017/5/11 10:18:26","1","","指纹","" ,"于","009","2017/5/11 11:25:47","1","","指纹","" ,"于","009","2017/5/11 13:49:23","1","","指纹","" ,"于","009","2017/5/11 14:02:04","1","","指纹","" ,"于","009","2017/5/11 16:58:33","1","","指纹","" ,"于","009","2017/5/11 18:23:28","1","","指纹","" ,"于","009","2017/5/12 8:49:37","1","","指纹","" ,"于","009","2017/5/12 11:27:42","1","","指纹","" ,"于","009","2017/5/12 13:47:13","1","","指纹","" ,"于","009","2017/5/12 14:10:01","1","","指纹","" ,"于","009","2017/5/12 15:52:46","1","","指纹","" ,"于","009","2017/5/12 17:30:29","1","","指纹","" ,"于","009","2017/5/12 18:09:34","1","","指纹","" ,"于","009","2017/5/15 8:50:10","1","","指纹","" ,"于","009","2017/5/15 13:38:37","1","","指纹",""

关于jsp用session传递list 在另一页面获取并遍历输出list

如题 ``` List<shuxing> list = new ArrayList<shuxing>(); shuxing s=new shuxing(); while(rs.next()){ s.setsShopName(rs.getString("sShopName")); s.setiNumbHj(rs.getString("iNumbHj")); s.setrMoneyHj(rs.getString("rMoneyHj")); list.add(s); } session.setAttribute("rs",list); response.sendRedirect("dian.jsp"); conn.close(); 获取 <c:forEach items="rs" var="user" > <c:out value="${user.sShopName}"/> </c:forEach> ``` 这样写报错HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: An exception occurred processing JSP page /dian.jsp at line 55 52: <!-- Codrops top bar --><!--/ Codrops top bar --> 53: <!-- <td><%Object q=session.getAttribute("rs"); %><%=q %></td>--> 54: <c:forEach items="rs" var="user" > 55: <c:out value="${user.sShopName}"/> 56: 57: </c:forEach> 58: </div> Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

怎么把sql查询到的数据用java封装成对象放到list里?

![图片说明](https://img-ask.csdn.net/upload/201910/24/1571914834_228128.png)

数组循环遍历后的结果 放入list集合中 请各位大神帮帮忙 代码怎么写呀

``` //数组res for(int i = 0; i < res.length; i++){ numValue=res[i].toString(); System.out.print(res[i] + " "); } ``` 循环遍历后怎么放入list集合中 //List <String> list = new ArrayList<String>();

2019 AI开发者大会

2019 AI开发者大会(AI ProCon 2019)是由中国IT社区CSDN主办的AI技术与产业年度盛会。多年经验淬炼,如今蓄势待发:2019年9月6-7日,大会将有近百位中美顶尖AI专家、知名企业代表以及千余名AI开发者齐聚北京,进行技术解读和产业论证。我们不空谈口号,只谈技术,诚挚邀请AI业内人士一起共铸人工智能新篇章!

实现简单的文件系统

实验内容: 通过对具体的文件存储空间的管理、文件的物理结构、目录结构和文件操作的实现,加深对文件系统内部功能和实现过程的理解。 要求: 1.在内存中开辟一个虚拟磁盘空间作为文件存储器,在其上实现一个简

MIPS单周期CPU-组成原理实验-华中科技大学

使用logisim布线完成的MIPS单周期CPU,可支持28条指令。跑马灯的代码已经装入了寄存器,可以直接开启时钟运行。

2019数学建模A题高压油管的压力控制 省一论文即代码

2019数学建模A题高压油管的压力控制省一完整论文即详细C++和Matlab代码,希望对同学们有所帮助

基于QT和OpenCV的五子棋实现源码

一个简单的五子棋应用,基于QT和OpenCV的实现源码,通过相邻棋子判断是否获胜,不包含人工智能算法,适合新手入门

Git 实用技巧

这几年越来越多的开发团队使用了Git,掌握Git的使用已经越来越重要,已经是一个开发者必备的一项技能;但很多人在刚开始学习Git的时候会遇到很多疑问,比如之前使用过SVN的开发者想不通Git提交代码为什么需要先commit然后再去push,而不是一条命令一次性搞定; 更多的开发者对Git已经入门,不过在遇到一些代码冲突、需要恢复Git代码时候就不知所措,这个时候哪些对 Git掌握得比较好的少数人,就像团队中的神一样,在队友遇到 Git 相关的问题的时候用各种流利的操作来帮助队友于水火。 我去年刚加入新团队,发现一些同事对Git的常规操作没太大问题,但对Git的理解还是比较生疏,比如说分支和分支之间的关联关系、合并代码时候的冲突解决、提交代码前未拉取新代码导致冲突问题的处理等,我在协助处理这些问题的时候也记录各种问题的解决办法,希望整理后通过教程帮助到更多对Git操作进阶的开发者。 本期教程学习方法分为“掌握基础——稳步进阶——熟悉协作”三个层次。从掌握基础的 Git的推送和拉取开始,以案例进行演示,分析每一个步骤的操作方式和原理,从理解Git 工具的操作到学会代码存储结构、演示不同场景下Git遇到问题的不同处理方案。循序渐进让同学们掌握Git工具在团队协作中的整体协作流程。 在教程中会通过大量案例进行分析,案例会模拟在工作中遇到的问题,从最基础的代码提交和拉取、代码冲突解决、代码仓库的数据维护、Git服务端搭建等。为了让同学们容易理解,对Git简单易懂,文章中详细记录了详细的操作步骤,提供大量演示截图和解析。在教程的最后部分,会从提升团队整体效率的角度对Git工具进行讲解,包括规范操作、Gitlab的搭建、钩子事件的应用等。 为了让同学们可以利用碎片化时间来灵活学习,在教程文章中大程度降低了上下文的依赖,让大家可以在工作之余进行学习与实战,并同时掌握里面涉及的Git不常见操作的相关知识,理解Git工具在工作遇到的问题解决思路和方法,相信一定会对大家的前端技能进阶大有帮助。

实用主义学Python(小白也容易上手的Python实用案例)

原价169,限时立减100元! 系统掌握Python核心语法16点,轻松应对工作中80%以上的Python使用场景! 69元=72讲+源码+社群答疑+讲师社群分享会&nbsp; 【哪些人适合学习这门课程?】 1)大学生,平时只学习了Python理论,并未接触Python实战问题; 2)对Python实用技能掌握薄弱的人,自动化、爬虫、数据分析能让你快速提高工作效率; 3)想学习新技术,如:人工智能、机器学习、深度学习等,这门课程是你的必修课程; 4)想修炼更好的编程内功,优秀的工程师肯定不能只会一门语言,Python语言功能强大、使用高效、简单易学。 【超实用技能】 从零开始 自动生成工作周报 职场升级 豆瓣电影数据爬取 实用案例 奥运冠军数据分析 自动化办公:通过Python自动化分析Excel数据并自动操作Word文档,最终获得一份基于Excel表格的数据分析报告。 豆瓣电影爬虫:通过Python自动爬取豆瓣电影信息并将电影图片保存到本地。 奥运会数据分析实战 简介:通过Python分析120年间奥运会的数据,从不同角度入手分析,从而得出一些有趣的结论。 【超人气老师】 二两 中国人工智能协会高级会员 生成对抗神经网络研究者 《深入浅出生成对抗网络:原理剖析与TensorFlow实现》一书作者 阿里云大学云学院导师 前大型游戏公司后端工程师 【超丰富实用案例】 0)图片背景去除案例 1)自动生成工作周报案例 2)豆瓣电影数据爬取案例 3)奥运会数据分析案例 4)自动处理邮件案例 5)github信息爬取/更新提醒案例 6)B站百大UP信息爬取与分析案例 7)构建自己的论文网站案例

深度学习原理+项目实战+算法详解+主流框架(套餐)

深度学习系列课程从深度学习基础知识点开始讲解一步步进入神经网络的世界再到卷积和递归神经网络,详解各大经典网络架构。实战部分选择当下最火爆深度学习框架PyTorch与Tensorflow/Keras,全程实战演示框架核心使用与建模方法。项目实战部分选择计算机视觉与自然语言处理领域经典项目,从零开始详解算法原理,debug模式逐行代码解读。适合准备就业和转行的同学们加入学习! 建议按照下列课程顺序来进行学习 (1)掌握深度学习必备经典网络架构 (2)深度框架实战方法 (3)计算机视觉与自然语言处理项目实战。(按照课程排列顺序即可)

C/C++跨平台研发从基础到高阶实战系列套餐

一 专题从基础的C语言核心到c++ 和stl完成基础强化; 二 再到数据结构,设计模式完成专业计算机技能强化; 三 通过跨平台网络编程,linux编程,qt界面编程,mfc编程,windows编程,c++与lua联合编程来完成应用强化 四 最后通过基于ffmpeg的音视频播放器,直播推流,屏幕录像,

三个项目玩转深度学习(附1G源码)

从事大数据与人工智能开发与实践约十年,钱老师亲自见证了大数据行业的发展与人工智能的从冷到热。事实证明,计算机技术的发展,算力突破,海量数据,机器人技术等,开启了第四次工业革命的序章。深度学习图像分类一直是人工智能的经典任务,是智慧零售、安防、无人驾驶等机器视觉应用领域的核心技术之一,掌握图像分类技术是机器视觉学习的重中之重。针对现有线上学习的特点与实际需求,我们开发了人工智能案例实战系列课程。打造:以项目案例实践为驱动的课程学习方式,覆盖了智能零售,智慧交通等常见领域,通过基础学习、项目案例实践、社群答疑,三维立体的方式,打造最好的学习效果。

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

Python界面版学生管理系统

前不久上传了一个控制台版本的学生管理系统,这个是Python界面版学生管理系统,这个是使用pycharm开发的一个有界面的学生管理系统,基本的增删改查,里面又演示视频和完整代码,有需要的伙伴可以自行下

Vue.js 2.0之全家桶系列视频课程

基于新的Vue.js 2.3版本, 目前新全的Vue.js教学视频,让你少走弯路,直达技术前沿! 1. 包含Vue.js全家桶(vue.js、vue-router、axios、vuex、vue-cli、webpack、ElementUI等) 2. 采用笔记+代码案例的形式讲解,通俗易懂

linux“开发工具三剑客”速成攻略

工欲善其事,必先利其器。Vim+Git+Makefile是Linux环境下嵌入式开发常用的工具。本专题主要面向初次接触Linux的新手,熟练掌握工作中常用的工具,在以后的学习和工作中提高效率。

JAVA初级工程师面试36问(完结)

第三十一问: 说一下线程中sleep()和wait()区别? 1 . sleep()是让正在执行的线程主动让出CPU,当时间到了,在回到自己的线程让程序运行。但是它并没有释放同步资源锁只是让出。 2.wait()是让当前线程暂时退让出同步资源锁,让其他线程来获取到这个同步资源在调用notify()方法,才会让其解除wait状态,再次参与抢资源。 3. sleep()方法可以在任何地方使用,而wait()只能在同步方法或同步块使用。 ...

java jdk 8 帮助文档 中文 文档 chm 谷歌翻译

JDK1.8 API 中文谷歌翻译版 java帮助文档 JDK API java 帮助文档 谷歌翻译 JDK1.8 API 中文 谷歌翻译版 java帮助文档 Java最新帮助文档 本帮助文档是使用谷

我以为我对Mysql事务很熟,直到我遇到了阿里面试官

太惨了,面试又被吊打

智鼎(附答案).zip

并不是完整题库,但是有智鼎在线2019年9、10、11三个月的试题,有十七套以上题目,普通的网申行测题足以对付,可以在做题时自己总结一些规律,都不是很难

Visual Assist X 破解补丁

vs a's'sixt插件 支持vs2008-vs2019 亲测可以破解,希望可以帮助到大家

150讲轻松搞定Python网络爬虫

【为什么学爬虫?】 &nbsp; &nbsp; &nbsp; &nbsp;1、爬虫入手容易,但是深入较难,如何写出高效率的爬虫,如何写出灵活性高可扩展的爬虫都是一项技术活。另外在爬虫过程中,经常容易遇到被反爬虫,比如字体反爬、IP识别、验证码等,如何层层攻克难点拿到想要的数据,这门课程,你都能学到! &nbsp; &nbsp; &nbsp; &nbsp;2、如果是作为一个其他行业的开发者,比如app开发,web开发,学习爬虫能让你加强对技术的认知,能够开发出更加安全的软件和网站 【课程设计】 一个完整的爬虫程序,无论大小,总体来说可以分成三个步骤,分别是: 网络请求:模拟浏览器的行为从网上抓取数据。 数据解析:将请求下来的数据进行过滤,提取我们想要的数据。 数据存储:将提取到的数据存储到硬盘或者内存中。比如用mysql数据库或者redis等。 那么本课程也是按照这几个步骤循序渐进的进行讲解,带领学生完整的掌握每个步骤的技术。另外,因为爬虫的多样性,在爬取的过程中可能会发生被反爬、效率低下等。因此我们又增加了两个章节用来提高爬虫程序的灵活性,分别是: 爬虫进阶:包括IP代理,多线程爬虫,图形验证码识别、JS加密解密、动态网页爬虫、字体反爬识别等。 Scrapy和分布式爬虫:Scrapy框架、Scrapy-redis组件、分布式爬虫等。 通过爬虫进阶的知识点我们能应付大量的反爬网站,而Scrapy框架作为一个专业的爬虫框架,使用他可以快速提高我们编写爬虫程序的效率和速度。另外如果一台机器不能满足你的需求,我们可以用分布式爬虫让多台机器帮助你快速爬取数据。 &nbsp; 从基础爬虫到商业化应用爬虫,本套课程满足您的所有需求! 【课程服务】 专属付费社群+每周三讨论会+1v1答疑

JavaWEB商城项目(包括数据库)

功能描述:包括用户的登录注册,以及个人资料的修改.商品的分类展示,详情,加入购物车,生成订单,到银行支付等!另外还有收货地址的和我的收藏等常用操作.环境(JDK 1.7 ,mysql 5.5,Ecli

Python数据挖掘简易入门

&nbsp; &nbsp; &nbsp; &nbsp; 本课程为Python数据挖掘方向的入门课程,课程主要以真实数据为基础,详细介绍数据挖掘入门的流程和使用Python实现pandas与numpy在数据挖掘方向的运用,并深入学习如何运用scikit-learn调用常用的数据挖掘算法解决数据挖掘问题,为进一步深入学习数据挖掘打下扎实的基础。

一学即懂的计算机视觉(第一季)

图像处理和计算机视觉的课程大家已经看过很多,但总有“听不透”,“用不了”的感觉。课程致力于创建人人都能听的懂的计算机视觉,通过生动、细腻的讲解配合实战演练,让学生真正学懂、用会。 【超实用课程内容】 课程内容分为三篇,包括视觉系统构成,图像处理基础,特征提取与描述,运动跟踪,位姿估计,三维重构等内容。课程理论与实战结合,注重教学内容的可视化和工程实践,为人工智能视觉研发及算法工程师等相关高薪职位就业打下坚实基础。 【课程如何观看?】 PC端:https://edu.csdn.net/course/detail/26281 移动端:CSDN 学院APP(注意不是CSDN APP哦) 本课程为录播课,课程2年有效观看时长,但是大家可以抓紧时间学习后一起讨论哦~ 【学员专享增值服务】 源码开放 课件、课程案例代码完全开放给你,你可以根据所学知识,自行修改、优化 下载方式:电脑登录https://edu.csdn.net/course/detail/26281,点击右下方课程资料、代码、课件等打包下载

软件测试2小时入门

本课程内容系统、全面、简洁、通俗易懂,通过2个多小时的介绍,让大家对软件测试有个系统的理解和认识,具备基本的软件测试理论基础。 主要内容分为5个部分: 1 软件测试概述,了解测试是什么、测试的对象、原则、流程、方法、模型;&nbsp; 2.常用的黑盒测试用例设计方法及示例演示;&nbsp; 3 常用白盒测试用例设计方法及示例演示;&nbsp; 4.自动化测试优缺点、使用范围及示例‘;&nbsp; 5.测试经验谈。

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

课程主要面向嵌入式Linux初学者、工程师、学生 主要从一下几方面进行讲解: 1.linux学习路线、基本命令、高级命令 2.shell、vi及vim入门讲解 3.软件安装下载、NFS、Samba、FTP等服务器配置及使用

2019 Python开发者日-培训

本次活动将秉承“只讲技术,拒绝空谈”的理念,邀请十余位身处一线的Python技术专家,重点围绕Web开发、自动化运维、数据分析、人工智能等技术模块,分享真实生产环境中使用Python应对IT挑战的真知灼见。此外,针对不同层次的开发者,大会还安排了深度培训实操环节,为开发者们带来更多深度实战的机会。

快速入门Android开发 视频 教程 android studio

这是一门快速入门Android开发课程,顾名思义是让大家能快速入门Android开发。 学完能让你学会如下知识点: Android的发展历程 搭建Java开发环境 搭建Android开发环境 Android Studio基础使用方法 Android Studio创建项目 项目运行到模拟器 项目运行到真实手机 Android中常用控件 排查开发中的错误 Android中请求网络 常用Android开发命令 快速入门Gradle构建系统 项目实战:看美图 常用Android Studio使用技巧 项目签名打包 如何上架市场

机器学习初学者必会的案例精讲

通过六个实际的编码项目,带领同学入门人工智能。这些项目涉及机器学习(回归,分类,聚类),深度学习(神经网络),底层数学算法,Weka数据挖掘,利用Git开源项目实战等。

4小时玩转微信小程序——基础入门与微信支付实战

这是一个门针对零基础学员学习微信小程序开发的视频教学课程。课程采用腾讯官方文档作为教程的唯一技术资料来源。杜绝网络上质量良莠不齐的资料给学员学习带来的障碍。 视频课程按照开发工具的下载、安装、使用、程序结构、视图层、逻辑层、微信小程序等几个部分组织课程,详细讲解整个小程序的开发过程

相关热词 c#分级显示数据 c# 不区分大小写替换 c#中调用就java c#正则表达式 验证小数 c# vscode 配置 c#三维数组能存多少数据 c# 新建excel c#多个文本框 c#怎么创建tcp通讯 c# mvc 电子病例
立即提问