• 
    

      <address id="upfr9"><pre id="upfr9"><strike id="upfr9"></strike></pre></address>
      1. <address id="upfr9"><tr id="upfr9"></tr></address><dl id="upfr9"></dl>

        java代碼行統(tǒng)計(jì),java代碼行統(tǒng)計(jì)工具

        要求用java代碼實(shí)現(xiàn):統(tǒng)計(jì)一個(gè)類總共產(chǎn)生的實(shí)例對(duì)象個(gè)數(shù)的功能

        public class MyDemo {

        10年積累的成都網(wǎng)站建設(shè)、成都做網(wǎng)站經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站設(shè)計(jì)制作后付款的網(wǎng)站建設(shè)流程,更有濮陽縣免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

        static int count = 0;

        // 每次調(diào)用任意構(gòu)造方法實(shí)例化都會(huì)執(zhí)行

        {

        count++;

        }

        // 提供方法返回實(shí)例化過的次數(shù)

        public static int getCount() {

        return count;

        }

        }

        java讀取txt文件,并統(tǒng)計(jì)每行中每個(gè)字母出現(xiàn)的次數(shù),并將產(chǎn)生的數(shù)字保存到一個(gè)新的txt文件中(有加分)

        import java.io.BufferedInputStream;

        import java.io.FileInputStream;

        import java.io.IOException;

        import java.io.InputStreamReader;

        import java.util.ArrayList;

        import java.util.Collections;

        import java.util.Comparator;

        import java.util.HashMap;

        import java.util.HashSet;

        import java.util.List;

        import java.util.Map;

        import java.util.Map.Entry;

        import java.util.Set;

        /**

        * 統(tǒng)計(jì)一部小說中文字?jǐn)?shù)量

        *

        */

        public class Demo10 {

        static int count = 0;

        public static void main(String[] args)throws IOException{

        String file = "src/javase2/day03/demo.txt";

        MapCharacter, Integer map = count(file);

        ListEntryCharacter, Integer entrys =

        new ArrayListEntryCharacter,Integer(map.entrySet());

        Collections.sort(entrys,

        new ComparatorEntryCharacter, Integer() {

        public int compare(EntryCharacter, Integer o1,

        EntryCharacter, Integer o2) {

        return -(o1.getValue() - o2.getValue());

        }

        });

        int all = map.size();

        System.out.println("不重復(fù)字符數(shù)量:"+ all);

        System.out.println("總字符數(shù)量:"+ count);

        for(int i=0; i10; i++){

        EntryCharacter, Integer entry = entrys.get(i);

        char c = entry.getKey();

        int val = entry.getValue();

        System.out.println(c+":"+val+","+(val*100.0/count)+"%");

        }

        }

        public static MapCharacter, Integer count(String file)

        throws IOException {

        InputStreamReader in =

        new InputStreamReader(

        new BufferedInputStream(

        new FileInputStream(file)),"GBK");

        MapCharacter, Integer map =

        new HashMapCharacter, Integer();

        SetCharacter ignoreChars = new HashSetCharacter();

        //ignoreChars 忽略的字符

        ignoreChars.add('\n');

        ignoreChars.add('\r');

        ignoreChars.add(',');

        ignoreChars.add('。');

        ignoreChars.add(' ');

        ignoreChars.add(' ');//...

        int c;

        while((c = in.read())!=-1){

        char ch = (char)c;

        if(ignoreChars.contains(ch)){

        continue;

        }

        count++;

        Integer val = map.get(ch);

        map.put(ch, val == null ? 1 : val+1);

        }

        in.close();

        return map;

        }

        }

        翻了一下以前的案例,給你找到了 ?你可以試試

        下面的這個(gè)是一個(gè)IO 的工具類

        import java.io.ByteArrayInputStream;

        import java.io.ByteArrayOutputStream;

        import java.io.File;

        import java.io.FileInputStream;

        import java.io.FileOutputStream;

        import java.io.IOException;

        import java.io.InputStream;

        import java.io.ObjectInputStream;

        import java.io.ObjectOutputStream;

        import java.io.OutputStream;

        import java.io.RandomAccessFile;

        import javax.imageio.stream.FileImageInputStream;

        /**

        * IO 工具類

        */

        public class IOUtils {

        public static Object deepCopy(Object obj) {

        try {

        ByteArrayOutputStream buf =

        new ByteArrayOutputStream();

        ObjectOutputStream oos = new ObjectOutputStream(buf);

        oos.writeObject(obj);// 將對(duì)象序列化到byte數(shù)組流中

        oos.close();

        byte[] ary = buf.toByteArray();

        ObjectInputStream ois = new ObjectInputStream(

        new ByteArrayInputStream(ary));

        Object o = ois.readObject();// 從byte數(shù)組流中反序列化對(duì)象

        ois.close();

        return o;

        } catch (Exception e) {// 異常捕獲再拋出, 將異常轉(zhuǎn)換為運(yùn)行時(shí)異常

        throw new RuntimeException(e);

        }

        }

        /**

        * 復(fù)制文件功能: 將文件src復(fù)制為dst

        * 只能復(fù)制文件! 不支持文件夾的復(fù)制!

        * @param src 源文件

        * @param dst 目標(biāo)文件

        */

        public static void cp(String src, String dst){

        try {

        InputStream in = new FileInputStream(src);

        OutputStream out = new FileOutputStream(dst);

        byte[] buf = new byte[10*1024];

        int count;

        while((count=in.read(buf))!=-1){

        //System.out.println(count);

        out.write(buf, 0, count);

        }

        //System.out.println("結(jié)束了:"+count);

        in.close();

        out.close();

        } catch (IOException e) {

        throw new RuntimeException(e);

        }

        }

        public static void cp2(String src, String dst){

        try {

        InputStream in = new FileInputStream(src);

        OutputStream out = new FileOutputStream(dst);

        int b;

        while((b=in.read())!=-1){

        out.write(b);

        }

        in.close();

        out.close();

        } catch (IOException e) {

        throw new RuntimeException(e);

        }

        }

        /**

        * 實(shí)現(xiàn)將文件讀取到一個(gè)byte數(shù)組

        */

        public static byte[] read2(String filename){

        try{

        InputStream in = new FileInputStream(filename);

        byte[] buf = new byte[in.available()];

        in.read(buf);

        in.close();

        return buf;

        }catch(IOException e){

        throw new RuntimeException(e);

        }

        }

        public static void print(File file){

        try{

        RandomAccessFile raf = new RandomAccessFile(file, "r");

        int b; int i=1;

        while((b=raf.read())!=-1){

        if(b=0xf)

        System.out.print("0");

        System.out.print(Integer.toHexString(b)+" ");

        if(i++%16 == 0){

        System.out.println();

        }

        }

        System.out.println();

        raf.close();

        }catch(IOException e){

        e.printStackTrace();

        throw new RuntimeException(e);

        }

        }

        public static void print(byte[] buf){

        int i=1;

        for(int b : buf){

        b = b 0xff;

        if(b=0xf)

        System.out.print("0");

        System.out.print(Integer.toHexString(b)+" ");

        if(i++%16 == 0){

        System.out.println();

        }

        }

        System.out.println();

        }

        /**

        * 將小文件 一次性 讀取到 byte數(shù)組中返回

        * @param file 文件名

        * @return 全部文件內(nèi)容

        */

        public static byte[] read(String file){

        try {

        RandomAccessFile raf = new RandomAccessFile(file, "r");

        byte[] buf = new byte[(int)raf.length()];

        raf.read(buf);

        raf.close();

        return buf;

        } catch (IOException e) {

        e.printStackTrace();

        throw new RuntimeException(e);

        }

        }

        public static byte[] read(File file){

        try {

        RandomAccessFile raf = new RandomAccessFile(file, "r");

        byte[] buf = new byte[(int)raf.length()];

        raf.read(buf);

        raf.close();

        return buf;

        } catch (IOException e) {

        e.printStackTrace();

        throw new RuntimeException(e);

        }

        }

        /**

        * 在控制臺(tái)上按照16進(jìn)制格式輸出文件的內(nèi)容

        * 每16個(gè)byte為一行

        * @param file 文件名

        * @throws RuntimeException 如果文件讀取失敗,跑出異常

        */

        public static void print(String file){//IOUtils.java

        try{

        RandomAccessFile raf=

        new RandomAccessFile(file, "r");

        int b; int i=1;

        while((b=raf.read())!=-1){

        if(b=0xf){ System.out.print('0'); }

        System.out.print(Integer.toHexString(b)+" ");

        if(i++%16==0){ System.out.println(); }

        }

        System.out.println();

        raf.close();?????

        }catch(IOException e){

        throw new RuntimeException(e);

        }

        }

        }

        如何統(tǒng)計(jì)一個(gè)時(shí)間段java代碼更新量

        使用代碼版本管理工具啊,例如svn、moven等等。 版本管理工具會(huì)記錄你的代碼更新情況,改動(dòng)、新增、刪除等操作都會(huì)詳細(xì)記錄的。 你安裝一個(gè)版本工具服務(wù)端和客戶端就行。

        當(dāng)前標(biāo)題:java代碼行統(tǒng)計(jì),java代碼行統(tǒng)計(jì)工具
        URL分享:http://www.jbt999.com/article46/phjchg.html

        成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、全網(wǎng)營銷推廣網(wǎng)站改版、網(wǎng)站收錄動(dòng)態(tài)網(wǎng)站、網(wǎng)站設(shè)計(jì)公司

        廣告

        聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

        成都網(wǎng)站建設(shè)公司

      2. 
        

          <address id="upfr9"><pre id="upfr9"><strike id="upfr9"></strike></pre></address>
          1. <address id="upfr9"><tr id="upfr9"></tr></address><dl id="upfr9"></dl>
            亚洲欧洲精品成人久久奇米网 | 免费在线观看亚洲视频 | 免费看A片秘 免费 | 一区二区三区电影网 | 免费无码毛片一区二区本码视频 | 天天爽天天狠 | www.666.日本高清 | 123好逼| 18禁无码永久免费网站大全 | 婷婷色网站 |