国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設(shè)計 > 正文

記事本君也賣萌

2019-11-14 22:19:30
字體:
供稿:網(wǎng)友
記事本君也賣萌

素材

                str[0] = "我跟你什么仇什么怨!!!!";        str[1] = "別拉我,我項鏈2000多!!!!";        str[2] = "騙了我,一百塊錢都不給我,還在笑!!!!!!!!";        str[3] = "歡迎嘴強王者";        str[4] = "我只想安靜地做一個美男子";        str[5] = "我今天又沒吃藥,感覺自己萌萌噠!!!!!!!!";        str[6] = "贊我的每人一包辣條,就是這么任性!!!!!!!!";        str[7] = "買買買,按斤買,不買不是人";        str[8] = "叔叔帶你裝逼帶你飛!!!!!!!!";        str[9] = "那畫面太美我不敢看!!!!!!!!";                
View Code

全部代碼

import java.io.BufferedReader;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStreamReader;import java.io.PRintWriter;public class OpenNotePad {        private Thread thread;    private String[] str;        public OpenNotePad() {        thread = new Thread(new InterThread());        str = new String[10];        str[0] = "我跟你什么仇什么怨!!!!";        str[1] = "別拉我,我項鏈2000多!!!!";        str[2] = "騙了我,一百塊錢都不給我,還在笑!!!!!!!!";        str[3] = "歡迎嘴強王者";        str[4] = "我只想安靜地做一個美男子";        str[5] = "我今天又沒吃藥,感覺自己萌萌噠!!!!!!!!";        str[6] = "贊我的每人一包辣條,就是這么任性!!!!!!!!";        str[7] = "買買買,按斤買,不買不是人";        str[8] = "叔叔帶你裝逼帶你飛!!!!!!!!";        str[9] = "那畫面太美我不敢看!!!!!!!!";     }    public static void main(String[] args) {        OpenNotePad object = new OpenNotePad();        object.startThread();            }        class InterThread implements Runnable{        @Override        public void run() {            openLocalNotepad(800,1700);        }            }        private void startThread(){        thread.start();    }        private void closedThread(Thread thread){        if(thread.isAlive() && thread != null){            try {                thread.join();            } catch (InterruptedException e) {                e.printStackTrace();            }        }    }        //設(shè)置打開次數(shù)    private int setTimes(int times){        return times;    }        //創(chuàng)建txt文件    private void createTxtFile(String name){        String filePath = "c://"+name+".txt";        File file = new File(filePath);        if(!file.exists()){            try {                file.createNewFile();            } catch (IOException e) {                // TODO Auto-generated catch block                e.printStackTrace();            }        }    }        private void deleteFile(String name){        String filePath = "c://"+name+".txt";        File file = new File(filePath);        if(file.exists()){            file.delete();        }    }    public  boolean writeTxtFile (String newStr,String name)         throws IOException {         // 先讀取原有文件內(nèi)容,然后進行寫入操作         boolean flag = false;         String filein = newStr + "/r/n/r/n";         String temp = "";         FileInputStream fis = null;         InputStreamReader isr = null;         BufferedReader br = null;         FileOutputStream fos = null;         PrintWriter pw = null;         try {             // 文件路徑             File file = new File("c://"+name+".txt");             // 將文件讀入輸入流             fis = new FileInputStream(file);             isr = new InputStreamReader(fis);             br = new BufferedReader(isr);             StringBuffer buf = new StringBuffer();                 // 保存該文件原有的內(nèi)容             for (int j = 1; (temp = br.readLine()) != null; j++) {             buf = buf.append(temp);             // System.getProperty("line.separator")             // 行與行之間的分隔符 相當于“/n”             buf = buf.append(System.getProperty("line.separator"));             }             buf.append(filein);                 fos = new FileOutputStream(file);             pw = new PrintWriter(fos);             pw.write(buf.toString().toCharArray());             pw.flush();             flag = true;         } catch (IOException e1) {         // TODO        throw e1;         } finally {             if (pw != null) {             pw.close();             }             if (fos != null) {             fos.close();             }             if (br != null) {             br.close();             }             if (isr != null) {             isr.close();             }             if (fis != null) {             fis.close();             }         }         return flag;     }             //參數(shù)可以加上時間延遲    private  void openLocalNotepad(long openDelay,long destroyDelay){        int openTimes = 0;        Process process = null;        while(openTimes < 10){            try {                Thread.sleep(openDelay);                createTxtFile(str[openTimes]);                writeTxtFile (str[openTimes],str[openTimes]);                process = Runtime.getRuntime().exec("notepad " +"c://"+str[openTimes]+".txt");                Thread.sleep(destroyDelay);                process.destroy();                deleteFile(str[openTimes]);            } catch (Exception e) {                e.printStackTrace();            }            openTimes++;        }        closedThread(thread);    }}
View Code

涉及內(nèi)部類,線程,文件等內(nèi)容。

讓記事本君也來買買萌,每隔2秒左右自動打開。

如下

具體可以下載下邊的jar包,直接執(zhí)行,當然需要Java運行環(huán)境。也可以編譯上邊的源碼

源碼純屬雕蟲小技,也有很多不規(guī)范,一笑而過。

打包的Jar文件地址:點我下載Jar包


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 邹平县| 松潘县| 盐源县| 襄城县| 吉木乃县| 张北县| 越西县| 西藏| 南和县| 双牌县| 兰考县| 安义县| 华蓥市| 报价| 萨嘎县| 英德市| 太原市| 类乌齐县| 黑龙江省| 隆林| 新乡县| 丹棱县| 马公市| 会同县| 都昌县| 多伦县| 龙井市| 邵武市| 芜湖县| 抚远县| 潼关县| 南华县| 邻水| 双鸭山市| 宜兰市| 烟台市| 焦作市| 福鼎市| 谷城县| 云安县| 海林市|