try {
Class.forName(driver);
System.out.println("H");
Connection conn = DriverManager.getConnection(url, user,
password);
Statement stat = conn.createStatement();
//Statement stat = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
PreparedStatement ps1 = (PreparedStatement) conn
.prepareStatement("insert mytable (file) values(?)");
//File file1 = new File("E:\\wps office\\ppt\\Decline.doc");
//InputStream inn = new FileInputStream(file1);
ServerSocket ss=new ServerSocket(9899);
Socket s=ss.accept();
System.out.println("连接成功");
InputStream inn=s.getInputStream();
ByteArrayOutputStream bt=new ByteArrayOutputStream();
System.out.println("1");
int c=inn.read();//读取bis流中的下一个字节
System.out.println("2");
while(c!=-1){
System.out.println("3");
bt.write(c);
System.out.println("4");
c=inn.read();
System.out.println("c :"+ c);
System.out.println("5");
}
System.out.println("6");
byte retArr[]=bt.toByteArray();
System.out.println("7");
System.out.println(retArr.length);
System.out.println("13dfasfagadfvadsfa");
ps1.setBinaryStream(1, inn,28);
System.out.println("13124111111111111111111111111111111111111111111");
ps1.executeUpdate();
System.out.println("13124");
InputStreamReader isr = new InputStreamReader(s.getInputStream());
BufferedReader br = new BufferedReader(isr);
pw = new PrintWriter(s.getOutputStream(), true);
while (true) {
String info = br.readLine();
System.out.println(info+"143254325");
jta.append("客户端 对 服务器 说:" + info + "\r\n");
}
} catch (Exception e) {
//e.printStackTrace();
System.out.println("bewukyqnk");
// TODO: handle exception
}
}
java 的InputStream 的read方法为何读取到最后没有返回值,且不往下执行了
答案:2 悬赏:0 手机版
解决时间 2021-02-12 22:18
- 提问者网友:龅牙恐龙妹
- 2021-02-11 22:14
最佳答案
- 五星知识达人网友:从此江山别
- 2021-02-11 22:23
问题还解决了??
全部回答
- 1楼网友:白昼之月
- 2021-02-11 22:42
byte[] b = new byte[16]; 你这里定义16字节,而文件中只有五个字符,一个字符就占一个字节,当然能读到5个了!
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯