`

apache commons io包快速入门

 
阅读更多
原文参考
http://www.javacodegeeks.com/2014/10/apache-commons-io-tutorial.html

  Apache Commons IO 包绝对是好东西,地址在http://commons.apache.org/proper/commons-io/,下面用例子分别介绍:
  1)  工具类
  2) 输入
  3) 输出
  4) filters过滤
  5) Comparators
  6) 文件监控
 
   总的入口例子为:
  
public class ApacheCommonsExampleMain {

    public static void main(String[] args) {
        UtilityExample.runExample();
        
        FileMonitorExample.runExample();
        
        FiltersExample.runExample();
        
        InputExample.runExample();
        
        OutputExample.runExample();
        
        ComparatorExample.runExample();
    }
}



一  工具类包UtilityExample代码:

    这个工具类包分如下几个主要工具类:
     1) FilenameUtils:主要处理各种操作系统下对文件名的操作
     2) FileUtils:处理文件的打开,移动,读取和判断文件是否存在
    3) IOCASE:字符串的比较
    4) FileSystemUtils:返回磁盘的空间大小

   

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileSystemUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.LineIterator;
import org.apache.commons.io.IOCase;

public final class UtilityExample {
    
    // We are using the file exampleTxt.txt in the folder ExampleFolder,
    // and we need to provide the full path to the Utility classes.
    private static final String EXAMPLE_TXT_PATH =
            "C:\\Users\\Lilykos\\workspace\\ApacheCommonsExample\\ExampleFolder\\exampleTxt.txt";
    
    private static final String PARENT_DIR =
            "C:\\Users\\Lilykos\\workspace\\ApacheCommonsExample";

    public static void runExample() throws IOException {
        System.out.println("Utility Classes example...");
        
        
        // FilenameUtils
        
        System.out.println("Full path of exampleTxt: " +
                FilenameUtils.getFullPath(EXAMPLE_TXT_PATH));
        
        System.out.println("Full name of exampleTxt: " +
                FilenameUtils.getName(EXAMPLE_TXT_PATH));
        
        System.out.println("Extension of exampleTxt: " +
                FilenameUtils.getExtension(EXAMPLE_TXT_PATH));
        
        System.out.println("Base name of exampleTxt: " +
                FilenameUtils.getBaseName(EXAMPLE_TXT_PATH));
        
        
        // FileUtils
        
        // We can create a new File object using FileUtils.getFile(String)
        // and then use this object to get information from the file.
        File exampleFile = FileUtils.getFile(EXAMPLE_TXT_PATH);
        LineIterator iter = FileUtils.lineIterator(exampleFile);
        
        System.out.println("Contents of exampleTxt...");
        while (iter.hasNext()) {
            System.out.println("\t" + iter.next());
        }
        iter.close();
        
        // We can check if a file exists somewhere inside a certain directory.
        File parent = FileUtils.getFile(PARENT_DIR);
        System.out.println("Parent directory contains exampleTxt file: " +
                FileUtils.directoryContains(parent, exampleFile));
        
        
        // IOCase
        
        String str1 = "This is a new String.";
        String str2 = "This is another new String, yes!";
        
        System.out.println("Ends with string (case sensitive): " +
                IOCase.SENSITIVE.checkEndsWith(str1, "string."));
        System.out.println("Ends with string (case insensitive): " +
                IOCase.INSENSITIVE.checkEndsWith(str1, "string."));
        
        System.out.println("String equality: " +
                IOCase.SENSITIVE.checkEquals(str1, str2));
        
        
        // FileSystemUtils
        System.out.println("Free disk space (in KB): " + FileSystemUtils.freeSpaceKb("C:"));
        System.out.println("Free disk space (in MB): " + FileSystemUtils.freeSpaceKb("C:") / 1024);
    }
}





输出:
Utility Classes example...
Full path of exampleTxt: C:\Users\Lilykos\workspace\ApacheCommonsExample\ExampleFolder\
Full name of exampleTxt: exampleTxt.txt
Extension of exampleTxt: txt
Base name of exampleTxt: exampleTxt
Contents of exampleTxt...
	This is an example text file.
	We will use it for experimenting with Apache Commons IO.
Parent directory contains exampleTxt file: true
Ends with string (case sensitive): false
Ends with string (case insensitive): true
String equality: false
Free disk space (in KB): 32149292
Free disk space (in MB): 31395



二  FileMonitor工具类包
   这个org.apache.commons.io.monitor 包中的工具类可以监视文件或者目录的变化,获得指定文件或者目录的相关信息,下面看例子:
  
import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileDeleteStrategy;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
import org.apache.commons.io.monitor.FileAlterationMonitor;
import org.apache.commons.io.monitor.FileAlterationObserver;
import org.apache.commons.io.monitor.FileEntry;


public final class FileMonitorExample {
    
    private static final String EXAMPLE_PATH =
            "C:\\Users\\Lilykos\\workspace\\ApacheCommonsExample\\ExampleFolder\\exampleFileEntry.txt";
    
    private static final String PARENT_DIR =
            "C:\\Users\\Lilykos\\workspace\\ApacheCommonsExample\\ExampleFolder";
    
    private static final String NEW_DIR =
            "C:\\Users\\Lilykos\\workspace\\ApacheCommonsExample\\ExampleFolder\\newDir";
    
    private static final String NEW_FILE =
            "C:\\Users\\Lilykos\\workspace\\ApacheCommonsExample\\ExampleFolder\\newFile.txt";

    public static void runExample() {
        System.out.println("File Monitor example...");
        
        
        // FileEntry
        
        // We can monitor changes and get information about files
        // using the methods of this class.
        FileEntry entry = new FileEntry(FileUtils.getFile(EXAMPLE_PATH));
        
        System.out.println("File monitored: " + entry.getFile());
        System.out.println("File name: " + entry.getName());
        System.out.println("Is the file a directory?: " + entry.isDirectory());
        
        
        // File Monitoring
        
        // Create a new observer for the folder and add a listener
        // that will handle the events in a specific directory and take action.
        File parentDir = FileUtils.getFile(PARENT_DIR);
        
        FileAlterationObserver observer = new FileAlterationObserver(parentDir);
        observer.addListener(new FileAlterationListenerAdaptor() {
            
                @Override
                public void onFileCreate(File file) {
                    System.out.println("File created: " + file.getName());
                }
                
                @Override
                public void onFileDelete(File file) {
                    System.out.println("File deleted: " + file.getName());
                }
                
                @Override
                public void onDirectoryCreate(File dir) {
                    System.out.println("Directory created: " + dir.getName());
                }
                
                @Override
                public void onDirectoryDelete(File dir) {
                    System.out.println("Directory deleted: " + dir.getName());
                }
        });
        
        // Add a monior that will check for events every x ms,
        // and attach all the different observers that we want.
        FileAlterationMonitor monitor = new FileAlterationMonitor(500, observer);
        try {
            monitor.start();
        
            // After we attached the monitor, we can create some files and directories
            // and see what happens!
            File newDir = new File(NEW_DIR);
            File newFile = new File(NEW_FILE);
            
            newDir.mkdirs();
            newFile.createNewFile();
                
            Thread.sleep(1000);
            
            FileDeleteStrategy.NORMAL.delete(newDir);
            FileDeleteStrategy.NORMAL.delete(newFile);
            
            Thread.sleep(1000);
            
            monitor.stop();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

输出如下:
  
File Monitor example...
File monitored: C:\Users\Lilykos\workspace\ApacheCommonsExample\ExampleFolder\exampleFileEntry.txt
File name: exampleFileEntry.txt
Is the file a directory?: false
Directory created: newDir
File created: newFile.txt
Directory deleted: newDir
File deleted: newFile.txt


    上面的特性的确很赞!分析下,这个工具类包下的工具类,可以允许我们创建跟踪文件或目录变化的监听句柄,当文件目录等发生任何变化,都可以用“观察者”的身份进行观察,
其步骤如下:
   1) 创建要监听的文件对象
   2) 创建FileAlterationObserver 监听对象,在上面的例子中,
   File parentDir = FileUtils.getFile(PARENT_DIR);
  FileAlterationObserver observer = new FileAlterationObserver(parentDir);
   创建的是监视parentDir目录的变化,
   3) 为观察器创建FileAlterationListenerAdaptor的内部匿名类,增加对文件及目录的增加删除的监听
   4) 创建FileAlterationMonitor监听类,每隔500ms监听目录下的变化,其中开启监视是用monitor的start方法即可。

三  过滤器 filters
   先看例子:
  

import java.io.File;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOCase;
import org.apache.commons.io.filefilter.AndFileFilter;
import org.apache.commons.io.filefilter.NameFileFilter;
import org.apache.commons.io.filefilter.NotFileFilter;
import org.apache.commons.io.filefilter.OrFileFilter;
import org.apache.commons.io.filefilter.PrefixFileFilter;
import org.apache.commons.io.filefilter.SuffixFileFilter;
import org.apache.commons.io.filefilter.WildcardFileFilter;

public final class FiltersExample {
    
    private static final String PARENT_DIR =
            "C:\\Users\\Lilykos\\workspace\\ApacheCommonsExample\\ExampleFolder";

    public static void runExample() {
        System.out.println("File Filter example...");
        
        
        // NameFileFilter
        // Right now, in the parent directory we have 3 files:
        //      directory example
        //      file exampleEntry.txt
        //      file exampleTxt.txt
        
        // Get all the files in the specified directory
        // that are named "example".
        File dir = FileUtils.getFile(PARENT_DIR);
        String[] acceptedNames = {"example", "exampleTxt.txt"};
        for (String file: dir.list(new NameFileFilter(acceptedNames, IOCase.INSENSITIVE))) {
            System.out.println("File found, named: " + file);
        }
        
        
        //WildcardFileFilter
        // We can use wildcards in order to get less specific results
        //      ? used for 1 missing char
        //      * used for multiple missing chars
        for (String file: dir.list(new WildcardFileFilter("*ample*"))) {
            System.out.println("Wildcard file found, named: " + file);
        }
        
        
        // PrefixFileFilter 
        // We can also use the equivalent of startsWith
        // for filtering files.
        for (String file: dir.list(new PrefixFileFilter("example"))) {
            System.out.println("Prefix file found, named: " + file);
        }
        
        
        // SuffixFileFilter
        // We can also use the equivalent of endsWith
        // for filtering files.
        for (String file: dir.list(new SuffixFileFilter(".txt"))) {
            System.out.println("Suffix file found, named: " + file);
        }
        
        
        // OrFileFilter 
        // We can use some filters of filters.
        // in this case, we use a filter to apply a logical 
        // or between our filters.
        for (String file: dir.list(new OrFileFilter(
                new WildcardFileFilter("*ample*"), new SuffixFileFilter(".txt")))) {
            System.out.println("Or file found, named: " + file);
        }
        
        // And this can become very detailed.
        // Eg, get all the files that have "ample" in their name
        // but they are not text files (so they have no ".txt" extension.
        for (String file: dir.list(new AndFileFilter( // we will match 2 filters...
                new WildcardFileFilter("*ample*"), // ...the 1st is a wildcard...
                new NotFileFilter(new SuffixFileFilter(".txt"))))) { // ...and the 2nd is NOT .txt.
            System.out.println("And/Not file found, named: " + file);
        }
    }
}

      可以看清晰看到,使用过滤器,可以分别在指定的目录下,寻找符合条件
的文件,比如以什么开头的文件名,支持通配符,甚至支持多个过滤器进行或的操作!
  输出如下:
 
File Filter example...
File found, named: example
File found, named: exampleTxt.txt
Wildcard file found, named: example
Wildcard file found, named: exampleFileEntry.txt
Wildcard file found, named: exampleTxt.txt
Prefix file found, named: example
Prefix file found, named: exampleFileEntry.txt
Prefix file found, named: exampleTxt.txt
Suffix file found, named: exampleFileEntry.txt
Suffix file found, named: exampleTxt.txt
Or file found, named: example
Or file found, named: exampleFileEntry.txt
Or file found, named: exampleTxt.txt
And/Not file found, named: example



四  Comparators比较器
   org.apache.commons.io.comparator包下的工具类,可以方便进行文件的比较:
import java.io.File;
import java.util.Date;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOCase;
import org.apache.commons.io.comparator.LastModifiedFileComparator;
import org.apache.commons.io.comparator.NameFileComparator;
import org.apache.commons.io.comparator.SizeFileComparator;

public final class ComparatorExample {
    
    private static final String PARENT_DIR =
            "C:\\Users\\Lilykos\\workspace\\ApacheCommonsExample\\ExampleFolder";
    
    private static final String FILE_1 =
            "C:\\Users\\Lilykos\\workspace\\ApacheCommonsExample\\ExampleFolder\\example";
    
    private static final String FILE_2 =
            "C:\\Users\\Lilykos\\workspace\\ApacheCommonsExample\\ExampleFolder\\exampleTxt.txt";
    
    public static void runExample() {
        System.out.println("Comparator example...");
        
        //NameFileComparator
        
        // Let's get a directory as a File object
        // and sort all its files.
        File parentDir = FileUtils.getFile(PARENT_DIR);
        NameFileComparator comparator = new NameFileComparator(IOCase.SENSITIVE);
        File[] sortedFiles = comparator.sort(parentDir.listFiles());
        
        System.out.println("Sorted by name files in parent directory: ");
        for (File file: sortedFiles) {
            System.out.println("\t"+ file.getAbsolutePath());
        }
        
        
        // SizeFileComparator
        
        // We can compare files based on their size.
        // The boolean in the constructor is about the directories.
        //      true: directory's contents count to the size.
        //      false: directory is considered zero size.
        SizeFileComparator sizeComparator = new SizeFileComparator(true);
        File[] sizeFiles = sizeComparator.sort(parentDir.listFiles());
        
        System.out.println("Sorted by size files in parent directory: ");
        for (File file: sizeFiles) {
            System.out.println("\t"+ file.getName() + " with size (kb): " + file.length());
        }
        
        
        // LastModifiedFileComparator
        
        // We can use this class to find which file was more recently modified.
        LastModifiedFileComparator lastModified = new LastModifiedFileComparator();
        File[] lastModifiedFiles = lastModified.sort(parentDir.listFiles());
        
        System.out.println("Sorted by last modified files in parent directory: ");
        for (File file: lastModifiedFiles) {
            Date modified = new Date(file.lastModified());
            System.out.println("\t"+ file.getName() + " last modified on: " + modified);
        }
        
        // Or, we can also compare 2 specific files and find which one was last modified.
        //      returns > 0 if the first file was last modified.
        //      returns  0)
            System.out.println("File " + file1.getName() + " was modified last because...");
        else
            System.out.println("File " + file2.getName() + "was modified last because...");
        
        System.out.println("\t"+ file1.getName() + " last modified on: " +
                new Date(file1.lastModified()));
        System.out.println("\t"+ file2.getName() + " last modified on: " +
                new Date(file2.lastModified()));
    }
}


   输出如下:
Comparator example...
Sorted by name files in parent directory: 
	C:\Users\Lilykos\workspace\ApacheCommonsExample\ExampleFolder\comparator1.txt
	C:\Users\Lilykos\workspace\ApacheCommonsExample\ExampleFolder\comperator2.txt
	C:\Users\Lilykos\workspace\ApacheCommonsExample\ExampleFolder\example
	C:\Users\Lilykos\workspace\ApacheCommonsExample\ExampleFolder\exampleFileEntry.txt
	C:\Users\Lilykos\workspace\ApacheCommonsExample\ExampleFolder\exampleTxt.txt
Sorted by size files in parent directory: 
	example with size (kb): 0
	exampleTxt.txt with size (kb): 87
	exampleFileEntry.txt with size (kb): 503
	comperator2.txt with size (kb): 1458
	comparator1.txt with size (kb): 4436
Sorted by last modified files in parent directory: 
	exampleTxt.txt last modified on: Sun Oct 26 14:02:22 EET 2014
	example last modified on: Sun Oct 26 23:42:55 EET 2014
	comparator1.txt last modified on: Tue Oct 28 14:48:28 EET 2014
	comperator2.txt last modified on: Tue Oct 28 14:48:52 EET 2014
	exampleFileEntry.txt last modified on: Tue Oct 28 14:53:50 EET 2014
File example was modified last because...
	example last modified on: Sun Oct 26 23:42:55 EET 2014
	exampleTxt.txt last modified on: Sun Oct 26 14:02:22 EET 2014



    可以看到,在上面的代码中
NameFileComparator: 文件名的比较器,可以进行文件名称排序;
SizeFileComparator: 按照文件大小比较
LastModifiedFileComparator: 根据最新修改日期比较

五  input包
    在 common io的org.apache.commons.io.input 包中,有各种对InputStream的实现类:
我们看下其中的TeeInputStream, ,它接受InputStream和Outputstream参数,例子如下:
  
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.input.TeeInputStream;
import org.apache.commons.io.input.XmlStreamReader;


public final class InputExample {
    
    private static final String XML_PATH =
            "C:\\Users\\Lilykos\\workspace\\ApacheCommonsExample\\InputOutputExampleFolder\\web.xml";
    
    private static final String INPUT = "This should go to the output.";

    public static void runExample() {
        System.out.println("Input example...");
        XmlStreamReader xmlReader = null;
        TeeInputStream tee = null;
        
        try {
            
            // XmlStreamReader
            
            // We can read an xml file and get its encoding.
            File xml = FileUtils.getFile(XML_PATH);
            
            xmlReader = new XmlStreamReader(xml);
            System.out.println("XML encoding: " + xmlReader.getEncoding());
            
            
            // TeeInputStream
            
            // This very useful class copies an input stream to an output stream
            // and closes both using only one close() method (by defining the 3rd
            // constructor parameter as true).
            ByteArrayInputStream in = new ByteArrayInputStream(INPUT.getBytes("US-ASCII"));
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            
            tee = new TeeInputStream(in, out, true);
            tee.read(new byte[INPUT.length()]);

            System.out.println("Output stream: " + out.toString());         
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try { xmlReader.close(); }
            catch (IOException e) { e.printStackTrace(); }
            
            try { tee.close(); }
            catch (IOException e) { e.printStackTrace(); }
        }
    }
}



输出:
  
Input example...
XML encoding: UTF-8
Output stream: This should go to the output.


   tee = new TeeInputStream(in, out, true);
   中,分别三个参数,将输入流的内容输出到输出流,true参数为最后关闭流
六 output工具类包
 
  其中的org.apache.commons.io.output 是实现了outputstream,其中好特别的是
TeeOutputStream能将一个输入流分别输出到两个输出流
  
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

import org.apache.commons.io.input.TeeInputStream;
import org.apache.commons.io.output.TeeOutputStream;

public final class OutputExample {
    
    private static final String INPUT = "This should go to the output.";

    public static void runExample() {
        System.out.println("Output example...");
        TeeInputStream teeIn = null;
        TeeOutputStream teeOut = null;
        
        try {
            
            // TeeOutputStream
            
            ByteArrayInputStream in = new ByteArrayInputStream(INPUT.getBytes("US-ASCII"));
            ByteArrayOutputStream out1 = new ByteArrayOutputStream();
            ByteArrayOutputStream out2 = new ByteArrayOutputStream();
            
            teeOut = new TeeOutputStream(out1, out2);
            teeIn = new TeeInputStream(in, teeOut, true);
            teeIn.read(new byte[INPUT.length()]);

            System.out.println("Output stream 1: " + out1.toString());
            System.out.println("Output stream 2: " + out2.toString());
            
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // No need to close teeOut. When teeIn closes, it will also close its
            // Output stream (which is teeOut), which will in turn close the 2
            // branches (out1, out2).
            try { teeIn.close(); }
            catch (IOException e) { e.printStackTrace(); }
        }
    }
}



  输出:
Output example...
Output stream 1: This should go to the output.
Output stream 2: This should go to the output.


完整代码下载:http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/10/ApacheCommonsIOExample.rar
7
6
分享到:
评论

相关推荐

    Apache common io转码工具类入门教程

    Apache Commons IO是Apache软件基金会开发的一个Java库,它提供了大量的实用工具类,简化了I/O操作,包括文件、流、过滤器、读写操作、转码等。在本教程中,我们将深入探讨如何使用Apache Commons IO进行转码,特别...

    commons-io-2.4-docs

    io utils 是apache 提供的方便数据操作的jar包,此文档有助于快速入门

    Java学习jar包绝对超值

    这个超值的jar包集合旨在帮助初学者快速入门,同时也为经验丰富的开发者节省了查找和集成不同库的时间。 首先,数据库相关的jar包是Java开发中的重要组成部分。例如,包含MySQL、Oracle、SQL Server、PostgreSQL等...

    Quartz框架快速入门

    ### Quartz框架快速入门详解 #### 一、Quartz框架简介 Quartz是一个开源的作业调度框架,用于开发Java应用程序。它提供了强大的触发器(Trigger)机制用于关联作业(Job),同时还具备灵活的表达式用于配置定时...

    poi相关架包

    【标题】:“poi相关架包”指的是Apache POI项目中的必备库文件,这些库使得开发者能够在Java环境中读取、写入以及操作Microsoft Office格式的...而这个“poi相关架包”正是开发者快速入门并进行相关开发工作的基础。

    JavaSE基础入门视频教程33天之(25) part2

    3. ** Commons-IO 工具类**:Apache Commons IO是一个包含大量实用工具方法的库,简化了Java的IO操作。在`day25_19`中,教程会介绍这个工具类库,而在`day25_21`和`22`中,将分别讲解`FilenameUtils`和`FileUtils`两...

    Jakarta.Commons.Cookbook

    《Jakarta.Commons.Cookbook》是一本专注于Apache Jakarta Commons组件使用的指南,它为开发者提供了大量实用的代码示例和技巧,帮助他们在Java应用程序开发中更有效地利用这些库。Apache Jakarta Commons是Apache...

    struts2项目使用的初级常用jar包

    - `commons-io.jar`:Apache Commons IO库,提供了大量I/O操作的工具类,如文件操作、流操作等。 - `commons-lang3.jar`:Apache Commons Lang库,提供了许多高级字符串和对象操作的工具类。 5. **Servlet容器...

    javaweb技术入门与开发

    "commons-io-1.3.2.jar"是Apache Commons IO库的一部分,提供了许多实用的输入/输出工具类,简化了文件操作和数据传输。 "commons-fileupload-1.2.jar"是Apache Commons FileUpload库,用于处理HTTP请求中的多部分...

    struts2入门框架搭建需要的jar

    7. **commons-io-2.5.jar**:Apache Commons IO库提供了各种I/O操作的工具类,如文件操作、流处理等。Struts2在处理文件上传、下载等场景时会用到这个库。 8. **servlet-api.jar**:Servlet API是Java Web开发的...

    Quartz_框架快速入门

    本文将引导您快速入门 Quartz 框架,了解其基本使用方法。 首先,要开始使用 Quartz,您需要从官方网站下载对应的 JAR 包,通常为 quartz-<version>.jar。除此之外,根据您的需求,Quartz 可能还需要一些第三方库,...

    Quartz 框架快速入门

    本篇文章将带你快速入门Quartz框架,了解如何在Spring中集成Quartz以及创建和执行Job。 首先,要使用Quartz框架,你需要在项目中引入必要的库文件。主要依赖的JAR是quartz-<version>.jar,此外,由于Quartz可能需要...

    Quartz框架快速入门.pdf

    import org.apache.commons.logging.LogFactory; import org.quartz.Job; import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; public class ...

    Android备忘录记事本,又加工了一下

    - **Apache Commons IO**:提供了文件和流操作的辅助方法。 4. **项目实践** 开发"SimpleNotePad"时,开发者需要实现以下功能: - 新增笔记:用户可以创建新的记事,输入文本并保存。 - 查看笔记:显示所有已...

    struts2 HelloWorld最小必备包

    这个"struts2 HelloWorld最小必备包"是初学者入门Struts2框架的起点,它包含了运行一个简单的"Hello, World!"示例所需的所有核心组件。 1. **Struts2 Core** (`struts2-core-2.5.2.jar`): 这是Struts2框架的核心...

    第一篇 环境的搭建和Hello World

    5. **commons-io.jar**:Apache Commons IO是Apache软件基金会的一个项目,提供了一系列与I/O相关的实用工具类,包括文件操作、流处理、字符集转换等。 6. **commons-fileupload-1.2.1.jar**:这是Apache Commons ...

    ssh框架整合包(jar)

    4. **其他支持库**:除了SSH框架本身的jar,整合包还可能包含一些必要的支持库,如Apache Commons库(用于各种通用功能)、Log4j(日志记录)、Commons-IO(I/O操作)、Commons-Net(网络操作)、JDBC驱动(对应不同...

    网络爬虫超级入门金典java

    import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.methods.GetMethod; ``` 此外,如果你想要使用更现代的HTTP客户端...

    客户信息管理软件 尚硅谷Java入门

    "apache"可能是指使用了Apache相关的技术,如Apache Tomcat作为Java应用服务器,或者使用了Apache的相关开源库,如Apache Commons来增强功能。 基于以上信息,我们可以深入讨论以下Java后端开发的关键知识点: 1. ...

Global site tag (gtag.js) - Google Analytics