代码如下,我这调用它根本停不下来啊!!!
- public void dir (String serName){
-
- System.out.println("以下是目录:");
- try {
-
- s = new Socket("10.12.39.27",8888);//连接服务器
- dis = new DataInputStream(new BufferedInputStream(s
- .getInputStream()));//定义数据输入流
- int BUFSIZE = 8912;
- byte[] buf = new byte[BUFSIZE];
- System.out.println("chdn");
- while (true) {
-
- int data = 0;//read用来保存从文件中读取过来的数据
- if (dis != null) {
- data= dis.read(buf);//遇到输入流的末尾,返回-1
- String str = new String(buf);
- System.out.println(str);
- }//读两次才执行跳出
- else if (data== -1) {
- System.out.println("跳出");
- break;
- }
- System.out.println("ssssssss");
- }
- System.out.println("zheng");
- } catch (IOException e) {
- System.out.println("错了");
- } finally {
- try {
- dis.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- s.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- System.out.println("asdf");
- }
- }
-
复制代码 |