岳阳企业网站定制开发网站优化哪个公司好
news/
2025/9/29 2:10:17/
文章来源:
岳阳企业网站定制开发,网站优化哪个公司好,外贸做消防的网站,一级建造师报名官网入口package IODemo;/*** author Alina* date 2021年11月15日 11:48 下午* 设计思想#xff1a;设计模式,装饰模式* JAVA中有23种设计思想#xff0c;全部基于面向对象* 装饰设计模式#xff0c;核心思想#xff0c;解决什么问题* 增强原有对象的功能**/
//第一…package IODemo;/*** author Alina* date 2021年11月15日 11:48 下午* 设计思想设计模式,装饰模式* JAVA中有23种设计思想全部基于面向对象* 装饰设计模式核心思想解决什么问题* 增强原有对象的功能**/
//第一代人类只有吃饭的功能
class Person{public void eat(){System.out.println(吃饱饭);}
}
//第二代人类有了新的吃法
class newPerson{private Person per;//提供构造函数public newPerson(Person pe) {this.per pe;}public void neweat(){System.out.println(喝奶茶);per.eat();System.out.println(吃巧克力);}
}public class buffer {public static void main(String[] args) {Person p new Person();newPerson n new newPerson(p);n.neweat();}
package IODemo;import java.io.*;/*** author Alina* date 2021年11月16日 11:35 下午* 实现读取文本一行* 读取一行返回字符串* 文件默认读到行位返回-1**/
class myread{private Reader reader;public myread(Reader reader) {this.reader reader;}public String readLine()throws IOException {//创建字符串缓冲区对象保留读取到的有效字符StringBuilder builder new StringBuilder();int len 0 ;//利用Reader类的方法read读取文件read 文件结尾返回-1while ((len reader.read())! -1){//判断读取到的是不是\rif (len \r){ continue;}//判断读取到的是否是\nif(len \n){return builder.toString();}//如果读取的不是\r\n 视为有效字符存放到缓冲区中builder.append((char) len);}//判断缓冲区是否有字符如果有返回去if(builder.length()!0){return builder.toString();}//文件读取完毕return null;}//定义关闭资源方法public void close()throws IOException{reader.close();}
}
public class myReadLine {public static void main(String[] args)throws IOException {myread my new myread(new FileReader(/src/IODemo/test.txt));String line null;while ((line my.readLine())!null){System.out.println(line);}// BufferedReader br new BufferedReader(new FileReader(/src/IODemo/test.txt));}}
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/921354.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!