日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【java作业】2、 编写两个函数,分别使用字节流、字符流实现文件的拷贝;点击按钮,将第三个文本框的字符串的值设置为第一个文本框的字符串+第二个文本框的字符串。

發布時間:2024/9/30 编程问答 37 豆豆

拷貝文件 :

public static void copy1(String a,String b) throws IOException {FileInputStream input = new FileInputStream(a);File file = new File(a);if(!file.canRead()||file.length() == 0) return ;FileOutputStream output = new FileOutputStream(b);int n = -1;while((n = input.read() )!= -1){String s = new String(hasRead,0,n);output.write(n);}input.close();output.close();}public static void copy2(String a,String b) throws IOException {FileReader input = new FileReader(a);File file = new File(a);if(!file.canRead()||file.length() == 0) return ;FileWriter output = new FileWriter(b);char c[]=new char[1000];int n = -1;while((n = input.read(c) )!= -1){output.write(c);}input.close();output.close();}

字符串拼接:

public static void main(String[]args){//InputArea newarea = new InputArea("name");Frame f=new Frame("字符串拼接");//設置分本框TextField tf1=new TextField(8);TextField tf2=new TextField(8);JButton b=new JButton("連接");TextField tf3=new TextField(15);//設置文本域//TextArea ta=new TextArea(10,40);f.setBounds(200, 200, 400, 300);//設置按鈕功能b.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {//獲取文本框的內容,并去除字符串前面和后面的空格String s=tf1.getText();String s2 = tf2.getText();}});}

為了防止作業雷同只寫了一部分代碼上去,如果需要全部的代碼私我就好。

總結

以上是生活随笔為你收集整理的【java作业】2、 编写两个函数,分别使用字节流、字符流实现文件的拷贝;点击按钮,将第三个文本框的字符串的值设置为第一个文本框的字符串+第二个文本框的字符串。的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。