示例
1 | Pattern imgPattern = Pattern.compile("<img (.+?)>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); |
1 | Pattern imgPattern = Pattern.compile("<img (.+?)>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); |
补充:官方不提供Windows下的zip版本下载
1.7
1 | cd ~/download |
1.8
1 | cd ~/download |
JSON Response
1 | response.setContentType("application/json"); |
HttpClient
1 | try { |
Java IO
1 | try (BufferedInputStream in = new BufferedInputStream(new URL(FILE_URL).openStream()); |
Java 7
1 | InputStream in = new URL(FILE_URL).openStream(); |
Read contents as String
1 | public static String URLReader(URL url) throws IOException { |
Java NIO
The transferTo() and transferFrom() methods are more efficient than simply reading from a stream using a buffer. Depending on the underlying operating system, the data can be transferred directly from the filesystem cache to our file without copying any bytes into the application memory.
On Linux and UNIX systems, these methods use the zero-copy technique that reduces the number of context switches between the kernel mode and user mode.
1 | URL website = new URL("http://www.website.com/information.asp"); |
Apache Commons IO
1 | FileUtils.copyURLToFile(new URL(FILE_URL), new File(FILE_NAME), CONNECT_TIMEOUT, READ_TIMEOUT); |
Java IO & NIO - Files.probeContentType()
1 | path = Files.createTempFile("test-file", ".html"); |
Determining a File Type In Java
MimetypesFileTypeMap.getContentType(String)
1 | final MimetypesFileTypeMap fileTypeMap = new MimetypesFileTypeMap(); |
URLConnection.getContentType()
1 | final URL url = new URL("file://" + fileName); |
Apache Tika
1 | Tika tika = new Tika(); |
mvn help:system
mvn help:effective-settings
java项目
1 | mvn archetype:generate -DgroupId=cc.aneat.example -DartifactId=example -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false |
java web项目
1 | mvn archetype:generate -DgroupId=com.travelight.framework -DartifactId=core -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false |
Project Object Model
名称 | |
---|---|
modelVersion | pom的版本只能是4.0.0 |
groupId | 组id |
artifactId | 模块id |
version | 版本号 |
packaging | 打包方式 (可选) |
name | 名称 (可选) |
url | 可选 |
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html