Java双语实验报告 Integrated Programming

上传人:无*** 文档编号:141575598 上传时间:2022-08-24 格式:DOC 页数:10 大小:950.83KB
返回 下载 相关 举报
Java双语实验报告 Integrated Programming_第1页
第1页 / 共10页
Java双语实验报告 Integrated Programming_第2页
第2页 / 共10页
Java双语实验报告 Integrated Programming_第3页
第3页 / 共10页
点击查看更多>>
资源描述
ReportClass: Name: No.:CourseJava Programming LanguageExperimentNameIntegrated ProgrammingTypeVerifyDemoIntegratedDesignTeacherScore1. Goal of this experiment (1)IO usage. (2)Learning programming. (3)Independent test and debug.2. Procedures (1)IO usage: Enter the following procedures. TestHow to use an exception here. (2)One applet Enter the following procedures. Add to an html page Write the lifecycle of applet. Learn the model of awt。 (3)Use Network Enter the following procedures. Test Learn how to use the network. (4)socket programming Enter the following procedures. Test Learn how to use the network. Summary way connection network resources Learn how to use the socket to communicate.Page 2 of 103. Recording of original data or result(1)IO usagepackage test;import java.io.*;public class MakeDirectories private static void usage() System.err.println(Usage:MakeDirectories path1 .n + Creates each pathn +Usage:MakeDirectories -d path1 .n +Deletes each pathn +Usage:MakeDirectories -r path1 path2n +Renames from path1 to path2);System.exit(1);private static void fileData(File f) System.out.println(Absolute path: + f.getAbsolutePath() +n Can read: + f.canRead() +n Can write: + f.canWrite() +n getName: + f.getName() +n getParent: + f.getParent() +n getPath: + f.getPath() +n length: + f.length() +n lastModified: + f.lastModified();if(f.isFile()System.out.println(Its a file);else if (f.isDirectory()System.out.println(Its a directory);public static void main(String args) if(args.length 1) usage();if(args0.equals(-r) if(args.length != 3) usage();File old = new File(args1);File rname = new File(args2);old.renameTo(rname);fileData(old);fileData(rname);return; / Exit mainint count = 0;boolean del = false;if(args0.equals(-d) count+;del = true;count-;while(+count args.length) File f = new File(argscount);if(f.exists() System.out.println(f + exists);if(del) System.out.println(deleting. + f);f.delete(); else / Doesnt existif(!del) f.mkdirs();System.out.println(created + f);fileData(f);You can determine whether a file exists, an exception is thrown when there is no(2) One applet:package test;import java.awt.*;import java.awt.event.*;import java.applet.Applet;public class Ex4_1 extends Applet implements ActionListener Label label1 = new Label(+);Label label2 = new Label(=);TextField field1 = new TextField(6);TextField field2 = new TextField(6);TextField field3 = new TextField(6);Button button1 = new Button(add);public void init() /initializeadd(field1);add(label1);add(field2);add(label2);add(field3);add(button1);button1.addActionListener(this);public void actionPerformed(ActionEvent e) int x = Integer.parseInt(field1.getText() + Integer.parseInt(field2.getText();field3.setText(Integer.toString(x);Insert title here(3)Use Network:package test;import .*;import java.io.*;public class URLTest public static void main(String args) URL url = null;InputStream is;tryurl=new URL();is = url.openStream();int c;try while(c = is.read() != -1)System.out.print(char)c);catch(IOException e) finally is.close();catch(MalformedURLException e) e.printStackTrace();catch(IOException e) e.printStackTrace();System.out.println(file name: + url.getFile(); System.out.println(host name: + url.getHost(); System.out.println(port no.: + url.getPort(); System.out.println(protocol name: + url.getProtocol();(4)socket programming:package test;import .*;import java.io.*;public class URLReader public static void main(String args) throws Exception URL web = new URL( BufferedReader in = new BufferedReader(new InputStreamReader(web.openStream();String inputLine;while (inputLine = in.readLine() != null) System.out.println(inputLine);in.close();4. Result and analysis(1)IO usage(2) One applet:1. applet lifecycle: Initialize (corresponding init method), runs (corresponding to the start method), the end of the run (corresponding stop method), destruction (corresponding to destroy method).2. awt the model: awt using mvc oop in the classic model, that model is responsible for storing data, view responsible for the display, controller responsible for the control view of the display according to the mode. Model components include Tree Model, Button Model more.(3)Use Network:(4)socket programmingSteps: first create a URL object by a unique URL for the resource, and then get the URL from the input stream InputStream object to read.Socket programming is about a ServerSocket and Socket to connect and transfer dataSignature:Date:7
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 管理文书 > 施工组织


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!