Skip to content

Commit f619920

Browse files
authored
Merge pull request eugenp#8190 from catalin-burcea/BAEL-19088
[BAEL-19088] - Move articles out of core-java-io part 3
2 parents e94fe4a + 5ec3630 commit f619920

File tree

95 files changed

+114
-180090
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+114
-180090
lines changed
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
# Intellij
2-
.idea/
3-
*.iml
1+
0.*
2+
3+
# Files generated by integration tests
4+
# *.txt
5+
/temp
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1+
## Core Java IO
12

2-
### Relevant Articles:
3+
This module contains articles about core Java input and output (IO)
34

5+
### Relevant Articles:
46
- [Create a File in a Specific Directory in Java](https://www.baeldung.com/java-create-file-in-directory)
7+
- [How to Read a Large File Efficiently with Java](https://www.baeldung.com/java-read-lines-large-file)
8+
- [Java – Write to File](https://www.baeldung.com/java-write-to-file)
9+
- [FileNotFoundException in Java](https://www.baeldung.com/java-filenotfound-exception)
10+
- [Delete the Contents of a File in Java](https://www.baeldung.com/java-delete-file-contents)
11+
- [List Files in a Directory in Java](https://www.baeldung.com/java-list-directory-files)
12+
- [Java – Append Data to a File](https://www.baeldung.com/java-append-to-file)
13+
- [How to Copy a File with Java](https://www.baeldung.com/java-copy-file)
14+
- [Create a Directory in Java](https://www.baeldung.com/java-create-directory)
15+
- [[<-- Prev]](/core-java-modules/core-java-io)

core-java-modules/core-java-io-2/pom.xml

Lines changed: 4 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -16,57 +16,16 @@
1616
<dependencies>
1717
<!-- utils -->
1818
<dependency>
19-
<groupId>net.sourceforge.collections</groupId>
20-
<artifactId>collections-generic</artifactId>
21-
<version>${collections-generic.version}</version>
22-
</dependency>
23-
<dependency>
24-
<groupId>org.apache.commons</groupId>
25-
<artifactId>commons-collections4</artifactId>
26-
<version>${commons-collections4.version}</version>
19+
<groupId>com.google.guava</groupId>
20+
<artifactId>guava</artifactId>
21+
<version>${guava.version}</version>
2722
</dependency>
23+
<!-- utils -->
2824
<dependency>
2925
<groupId>commons-io</groupId>
3026
<artifactId>commons-io</artifactId>
3127
<version>${commons-io.version}</version>
3228
</dependency>
33-
<dependency>
34-
<groupId>org.apache.commons</groupId>
35-
<artifactId>commons-lang3</artifactId>
36-
<version>${commons-lang3.version}</version>
37-
</dependency>
38-
<dependency>
39-
<groupId>org.apache.commons</groupId>
40-
<artifactId>commons-math3</artifactId>
41-
<version>${commons-math3.version}</version>
42-
</dependency>
43-
<dependency>
44-
<groupId>org.decimal4j</groupId>
45-
<artifactId>decimal4j</artifactId>
46-
<version>${decimal4j.version}</version>
47-
</dependency>
48-
<dependency>
49-
<groupId>org.bouncycastle</groupId>
50-
<artifactId>bcprov-jdk15on</artifactId>
51-
<version>${bouncycastle.version}</version>
52-
</dependency>
53-
<dependency>
54-
<groupId>org.unix4j</groupId>
55-
<artifactId>unix4j-command</artifactId>
56-
<version>${unix4j.version}</version>
57-
</dependency>
58-
<dependency>
59-
<groupId>com.googlecode.grep4j</groupId>
60-
<artifactId>grep4j</artifactId>
61-
<version>${grep4j.version}</version>
62-
</dependency>
63-
<!-- web -->
64-
<!-- marshalling -->
65-
<dependency>
66-
<groupId>com.fasterxml.jackson.core</groupId>
67-
<artifactId>jackson-databind</artifactId>
68-
<version>${jackson.version}</version>
69-
</dependency>
7029
<!-- logging -->
7130
<dependency>
7231
<groupId>log4j</groupId>
@@ -78,99 +37,13 @@
7837
<artifactId>log4j-over-slf4j</artifactId>
7938
<version>${org.slf4j.version}</version>
8039
</dependency>
81-
<dependency>
82-
<groupId>org.projectlombok</groupId>
83-
<artifactId>lombok</artifactId>
84-
<version>${lombok.version}</version>
85-
<scope>provided</scope>
86-
</dependency>
8740
<!-- test scoped -->
8841
<dependency>
8942
<groupId>org.assertj</groupId>
9043
<artifactId>assertj-core</artifactId>
9144
<version>${assertj.version}</version>
9245
<scope>test</scope>
9346
</dependency>
94-
<dependency>
95-
<groupId>com.jayway.awaitility</groupId>
96-
<artifactId>awaitility</artifactId>
97-
<version>${avaitility.version}</version>
98-
<scope>test</scope>
99-
</dependency>
100-
<dependency>
101-
<groupId>commons-codec</groupId>
102-
<artifactId>commons-codec</artifactId>
103-
<version>${commons-codec.version}</version>
104-
</dependency>
105-
<dependency>
106-
<groupId>org.javamoney</groupId>
107-
<artifactId>moneta</artifactId>
108-
<version>${moneta.version}</version>
109-
</dependency>
110-
<dependency>
111-
<groupId>org.owasp.esapi</groupId>
112-
<artifactId>esapi</artifactId>
113-
<version>${esapi.version}</version>
114-
</dependency>
115-
<dependency>
116-
<groupId>com.sun.messaging.mq</groupId>
117-
<artifactId>fscontext</artifactId>
118-
<version>${fscontext.version}</version>
119-
</dependency>
120-
<dependency>
121-
<groupId>com.codepoetics</groupId>
122-
<artifactId>protonpack</artifactId>
123-
<version>${protonpack.version}</version>
124-
</dependency>
125-
<dependency>
126-
<groupId>one.util</groupId>
127-
<artifactId>streamex</artifactId>
128-
<version>${streamex.version}</version>
129-
</dependency>
130-
<dependency>
131-
<groupId>io.vavr</groupId>
132-
<artifactId>vavr</artifactId>
133-
<version>${vavr.version}</version>
134-
</dependency>
135-
<dependency>
136-
<groupId>org.openjdk.jmh</groupId>
137-
<artifactId>jmh-core</artifactId>
138-
<version>${jmh-core.version}</version>
139-
</dependency>
140-
<dependency>
141-
<groupId>org.openjdk.jmh</groupId>
142-
<artifactId>jmh-generator-annprocess</artifactId>
143-
<version>${jmh-generator-annprocess.version}</version>
144-
</dependency>
145-
<dependency>
146-
<groupId>org.hsqldb</groupId>
147-
<artifactId>hsqldb</artifactId>
148-
<version>${hsqldb.version}</version>
149-
<scope>runtime</scope>
150-
</dependency>
151-
<!-- https://mvnrepository.com/artifact/org.asynchttpclient/async-http-client -->
152-
<dependency>
153-
<groupId>org.asynchttpclient</groupId>
154-
<artifactId>async-http-client</artifactId>
155-
<version>${async-http-client.version}</version>
156-
</dependency>
157-
<dependency>
158-
<groupId>com.opencsv</groupId>
159-
<artifactId>opencsv</artifactId>
160-
<version>${opencsv.version}</version>
161-
<scope>test</scope>
162-
</dependency>
163-
<!-- Mime Type Resolution Libraries -->
164-
<dependency>
165-
<groupId>org.apache.tika</groupId>
166-
<artifactId>tika-core</artifactId>
167-
<version>${tika.version}</version>
168-
</dependency>
169-
<dependency>
170-
<groupId>net.sf.jmimemagic</groupId>
171-
<artifactId>jmimemagic</artifactId>
172-
<version>${jmime-magic.version}</version>
173-
</dependency>
17447
</dependencies>
17548

17649
<build>
@@ -182,22 +55,6 @@
18255
</resource>
18356
</resources>
18457
<plugins>
185-
<plugin>
186-
<groupId>org.codehaus.mojo</groupId>
187-
<artifactId>exec-maven-plugin</artifactId>
188-
<version>${exec-maven-plugin.version}</version>
189-
<configuration>
190-
<executable>java</executable>
191-
<mainClass>com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed</mainClass>
192-
<arguments>
193-
<argument>-Xmx300m</argument>
194-
<argument>-XX:+UseParallelGC</argument>
195-
<argument>-classpath</argument>
196-
<classpath />
197-
<argument>com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed</argument>
198-
</arguments>
199-
</configuration>
200-
</plugin>
20158
<plugin>
20259
<groupId>org.apache.maven.plugins</groupId>
20360
<artifactId>maven-javadoc-plugin</artifactId>
@@ -210,70 +67,9 @@
21067
</plugins>
21168
</build>
21269

213-
<profiles>
214-
<profile>
215-
<id>integration</id>
216-
<build>
217-
<plugins>
218-
<plugin>
219-
<groupId>org.codehaus.mojo</groupId>
220-
<artifactId>exec-maven-plugin</artifactId>
221-
222-
<executions>
223-
<execution>
224-
<id>run-benchmarks</id>
225-
<!-- <phase>integration-test</phase> -->
226-
<phase>none</phase>
227-
<goals>
228-
<goal>exec</goal>
229-
</goals>
230-
<configuration>
231-
<classpathScope>test</classpathScope>
232-
<executable>java</executable>
233-
<arguments>
234-
<argument>-classpath</argument>
235-
<classpath />
236-
<argument>org.openjdk.jmh.Main</argument>
237-
<argument>.*</argument>
238-
</arguments>
239-
</configuration>
240-
</execution>
241-
</executions>
242-
</plugin>
243-
</plugins>
244-
</build>
245-
</profile>
246-
</profiles>
247-
24870
<properties>
249-
250-
<!-- util -->
251-
<bouncycastle.version>1.55</bouncycastle.version>
252-
<commons-codec.version>1.10</commons-codec.version>
253-
<commons-math3.version>3.6.1</commons-math3.version>
254-
<decimal4j.version>1.0.3</decimal4j.version>
255-
<commons-collections4.version>4.1</commons-collections4.version>
256-
<collections-generic.version>4.01</collections-generic.version>
257-
<unix4j.version>0.4</unix4j.version>
258-
<grep4j.version>1.8.7</grep4j.version>
259-
<fscontext.version>4.6-b01</fscontext.version>
260-
<protonpack.version>1.13</protonpack.version>
261-
<streamex.version>0.6.5</streamex.version>
262-
<vavr.version>0.9.0</vavr.version>
263-
<opencsv.version>4.1</opencsv.version>
264-
<!-- testing -->
26571
<assertj.version>3.6.1</assertj.version>
266-
<avaitility.version>1.7.0</avaitility.version>
267-
268-
<!-- maven plugins -->
26972
<maven-javadoc-plugin.version>3.0.0-M1</maven-javadoc-plugin.version>
270-
<hsqldb.version>2.4.0</hsqldb.version>
271-
<esapi.version>2.1.0.1</esapi.version>
272-
<jmh-generator-annprocess.version>1.19</jmh-generator-annprocess.version>
273-
<async-http-client.version>2.4.5</async-http-client.version>
274-
<!-- Mime Type Libraries -->
275-
<tika.version>1.18</tika.version>
276-
<jmime-magic.version>0.1.5</jmime-magic.version>
27773
</properties>
27874

27975
</project>

core-java-modules/core-java-io/src/main/java/com/baeldung/files/ListFiles.java renamed to core-java-modules/core-java-io-2/src/main/java/com/baeldung/listfiles/ListFiles.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.files;
1+
package com.baeldung.listfiles;
22

33
import java.io.File;
44
import java.io.IOException;

core-java-modules/core-java-io/src/test/java/com/baeldung/file/FilesManualTest.java renamed to core-java-modules/core-java-io-2/src/test/java/com/baeldung/appendtofile/AppendToFileManualTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.file;
1+
package com.baeldung.appendtofile;
22

33
import static org.assertj.core.api.Assertions.assertThat;
44

@@ -22,9 +22,7 @@
2222
import org.junit.Before;
2323
import org.junit.Test;
2424

25-
import com.baeldung.util.StreamUtils;
26-
27-
public class FilesManualTest {
25+
public class AppendToFileManualTest {
2826

2927
public static final String fileName = "src/main/resources/countries.properties";
3028

core-java-modules/core-java-io/src/main/java/com/baeldung/util/StreamUtils.java renamed to core-java-modules/core-java-io-2/src/test/java/com/baeldung/appendtofile/StreamUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package com.baeldung.util;
1+
package com.baeldung.appendtofile;
2+
3+
import org.apache.commons.io.IOUtils;
24

35
import java.io.IOException;
46
import java.io.InputStream;
57
import java.io.StringWriter;
68

7-
import org.apache.commons.io.IOUtils;
8-
99
public class StreamUtils {
1010

1111
public static String getStringFromInputStream(InputStream input) throws IOException {

core-java-modules/core-java-io-2/src/test/java/com/baeldung/createfiles/CreateFilesUnitTest.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,27 @@
55

66
import java.io.File;
77
import java.io.IOException;
8-
8+
import org.junit.BeforeClass;
99
import static org.junit.Assert.assertFalse;
1010
import static org.junit.Assert.assertTrue;
1111

1212
public class CreateFilesUnitTest {
13+
14+
@BeforeClass
15+
public static void clean() {
16+
File tempDirectory = new File(System.getProperty("java.io.tmpdir"));
17+
File file1 = new File(tempDirectory.getAbsolutePath() + "/testFile.txt");
18+
File file2 = new File(tempDirectory, "newFile.txt");
19+
File file3 = new File(tempDirectory.getAbsolutePath() + File.separator + "newFile2.txt");
20+
file1.delete();
21+
file2.delete();
22+
file3.delete();
23+
}
24+
1325
@Test
1426
public void givenAnExistingDirectory_whenCreatingAFileWithAbsolutePath_thenFileIsCreated() throws IOException {
1527
File tempDirectory = new File(System.getProperty("java.io.tmpdir"));
16-
File fileWithAbsolutePath = new File(tempDirectory.getAbsolutePath() + "/myDirectory/testFile.txt");
28+
File fileWithAbsolutePath = new File(tempDirectory.getAbsolutePath() + "/testFile.txt");
1729

1830
assertFalse(fileWithAbsolutePath.exists());
1931

@@ -25,7 +37,7 @@ public void givenAnExistingDirectory_whenCreatingAFileWithAbsolutePath_thenFileI
2537
@Test
2638
public void givenAnExistingDirectory_whenCreatingANewDirectoryAndFileWithRelativePath_thenFileIsCreated() throws IOException {
2739
File tempDirectory = new File(System.getProperty("java.io.tmpdir"));
28-
File fileWithRelativePath = new File(tempDirectory, "myDirectory/newFile.txt");
40+
File fileWithRelativePath = new File(tempDirectory, "newFile.txt");
2941

3042
assertFalse(fileWithRelativePath.exists());
3143

@@ -37,7 +49,7 @@ public void givenAnExistingDirectory_whenCreatingANewDirectoryAndFileWithRelativ
3749
@Test
3850
public void whenCreatingAFileWithFileSeparator_thenFileIsCreated() throws IOException {
3951
File tempDirectory = new File(System.getProperty("java.io.tmpdir"));
40-
File newFile = new File(tempDirectory.getAbsolutePath() + File.separator + "newFile.txt");
52+
File newFile = new File(tempDirectory.getAbsolutePath() + File.separator + "newFile2.txt");
4153

4254
assertFalse(newFile.exists());
4355

core-java-modules/core-java-io/src/test/java/com/baeldung/file/FilesClearDataUnitTest.java renamed to core-java-modules/core-java-io-2/src/test/java/com/baeldung/deletecontents/FilesClearDataUnitTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.file;
1+
package com.baeldung.deletecontents;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44

@@ -20,8 +20,6 @@
2020
import org.junit.Before;
2121
import org.junit.Test;
2222

23-
import com.baeldung.util.StreamUtils;
24-
2523
public class FilesClearDataUnitTest {
2624

2725
public static final String FILE_PATH = "src/test/resources/fileexample.txt";

0 commit comments

Comments
 (0)