JAVA-22516 Split or move core-java-io-apis-2 module (moved-1) (#14361)
* JAVA-22516 Split or move core-java-io-apis-2 module (moved-1) * JAVA-22516 Adding back the file after fixing the conflicts --------- Co-authored-by: timis1 <noreplay@yahoo.com>
This commit is contained in:
parent
346418a266
commit
f2ab4c2aa8
|
@ -4,13 +4,5 @@ This module contains articles about core Java input/output(IO) APIs.
|
|||
|
||||
### Relevant Articles:
|
||||
- [Constructing a Relative Path From Two Absolute Paths in Java](https://www.baeldung.com/java-relative-path-absolute)
|
||||
- [Java Scanner Taking a Character Input](https://www.baeldung.com/java-scanner-character-input)
|
||||
- [Get the Desktop Path in Java](https://www.baeldung.com/java-desktop-path)
|
||||
- [Integer.parseInt(scanner.nextLine()) and scanner.nextInt() in Java](https://www.baeldung.com/java-scanner-integer)
|
||||
- [Difference Between FileReader and BufferedReader in Java](https://www.baeldung.com/java-filereader-vs-bufferedreader)
|
||||
- [Java: Read Multiple Inputs on Same Line](https://www.baeldung.com/java-read-multiple-inputs-same-line)
|
||||
- [Storing Java Scanner Input in an Array](https://www.baeldung.com/java-store-scanner-input-in-array)
|
||||
- [How to Take Input as String With Spaces in Java Using Scanner?](https://www.baeldung.com/java-scanner-input-with-spaces)
|
||||
- [Write Console Output to Text File in Java](https://www.baeldung.com/java-write-console-output-file)
|
||||
- [What’s the difference between Scanner next() and nextLine() methods?](https://www.baeldung.com/java-scanner-next-vs-nextline)
|
||||
- [Handle NoSuchElementException When Reading a File Through Scanner](https://www.baeldung.com/java-scanner-nosuchelementexception-reading-file)
|
||||
- [Check if a File Is Empty in Java](https://www.baeldung.com/java-check-file-empty)
|
||||
|
|
|
@ -92,12 +92,6 @@
|
|||
<version>7.1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>7.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>core-java-io-apis-2</finalName>
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package com.baeldung.emptyfile;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
class CheckFileIsEmptyUnitTest {
|
||||
@Test
|
||||
void whenTheFileIsEmpty_thenFileLengthIsZero(@TempDir Path tempDir) throws IOException {
|
||||
File emptyFile = tempDir.resolve("an-empty-file.txt")
|
||||
.toFile();
|
||||
emptyFile.createNewFile();
|
||||
assertTrue(emptyFile.exists());
|
||||
assertEquals(0, emptyFile.length());
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenFileDoesNotExist_thenFileLengthIsZero(@TempDir Path tempDir) {
|
||||
File aNewFile = tempDir.resolve("a-new-file.txt")
|
||||
.toFile();
|
||||
assertFalse(aNewFile.exists());
|
||||
assertEquals(0, aNewFile.length());
|
||||
}
|
||||
|
||||
boolean isFileEmpty(File file) {
|
||||
if (!file.exists()) {
|
||||
throw new IllegalArgumentException("Cannot check the file length. The file is not found: " + file.getAbsolutePath());
|
||||
}
|
||||
return file.length() == 0;
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenTheFileDoesNotExist_thenIsFilesEmptyThrowsException(@TempDir Path tempDir) {
|
||||
File aNewFile = tempDir.resolve("a-new-file.txt")
|
||||
.toFile();
|
||||
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> isFileEmpty(aNewFile));
|
||||
assertEquals(ex.getMessage(), "Cannot check the file length. The file is not found: " + aNewFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenTheFileIsEmpty_thenIsFilesEmptyReturnsTrue(@TempDir Path tempDir) throws IOException {
|
||||
File emptyFile = tempDir.resolve("an-empty-file.txt")
|
||||
.toFile();
|
||||
emptyFile.createNewFile();
|
||||
assertTrue(isFileEmpty(emptyFile));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenTheFileIsEmpty_thenFilesSizeReturnsTrue(@TempDir Path tempDir) throws IOException {
|
||||
Path emptyFilePath = tempDir.resolve("an-empty-file.txt");
|
||||
Files.createFile(emptyFilePath);
|
||||
assertEquals(0, Files.size(emptyFilePath));
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenTheFileDoesNotExist_thenFilesSizeThrowsException(@TempDir Path tempDir) {
|
||||
Path aNewFilePath = tempDir.resolve("a-new-file.txt");
|
||||
assertThrows(NoSuchFileException.class, () -> Files.size(aNewFilePath));
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
## Core Java IO APIs
|
||||
|
||||
This module contains articles about core Java input/output(IO) APIs.
|
||||
|
||||
### Relevant Articles:
|
||||
- [Read Date in Java Using Scanner](https://www.baeldung.com/java-scanner-read-date)
|
||||
- [Check if a File Is Empty in Java](https://www.baeldung.com/java-check-file-empty)
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>core-java-io-apis-3</artifactId>
|
||||
<name>core-java-io-apis-3</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
</project>
|
|
@ -10,6 +10,6 @@ This module contains articles about core Java input/output(IO) APIs.
|
|||
- [Comparing getPath(), getAbsolutePath(), and getCanonicalPath() in Java](https://www.baeldung.com/java-path)
|
||||
- [Quick Use of FilenameFilter](https://www.baeldung.com/java-filename-filter)
|
||||
- [Guide to BufferedReader](https://www.baeldung.com/java-buffered-reader)
|
||||
- [Java Scanner](https://www.baeldung.com/java-scanner)
|
||||
- [Scanner nextLine() Method](https://www.baeldung.com/java-scanner-nextline)
|
||||
- [Java Scanner hasNext() vs. hasNextLine()](https://www.baeldung.com/java-scanner-hasnext-vs-hasnextline)
|
||||
- [Difference Between FileReader and BufferedReader in Java](https://www.baeldung.com/java-filereader-vs-bufferedreader)
|
||||
- [Java: Read Multiple Inputs on Same Line](https://www.baeldung.com/java-read-multiple-inputs-same-line)
|
||||
- [Write Console Output to Text File in Java](https://www.baeldung.com/java-write-console-output-file)
|
|
@ -31,6 +31,12 @@
|
|||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>7.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package com.baeldung.multinput;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.InputMismatchException;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testng.annotations.Test;
|
||||
import com.baeldung.multinput.MultiInputs;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.InputMismatchException;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class TestMultipleInputsUnitTest {
|
||||
@Test
|
||||
public void givenMultipleInputs_whenUsingSpaceDelimiter_thenExpectPrintingOutputs() {
|
|
@ -0,0 +1,15 @@
|
|||
## Core Java IO APIs
|
||||
|
||||
This module contains articles about core Java input/output(IO) APIs.
|
||||
|
||||
### Relevant Articles:
|
||||
- [Read Date in Java Using Scanner](https://www.baeldung.com/java-scanner-read-date)
|
||||
- [Java Scanner Taking a Character Input](https://www.baeldung.com/java-scanner-character-input)
|
||||
- [Integer.parseInt(scanner.nextLine()) and scanner.nextInt() in Java](https://www.baeldung.com/java-scanner-integer)
|
||||
- [Storing Java Scanner Input in an Array](https://www.baeldung.com/java-store-scanner-input-in-array)
|
||||
- [How to Take Input as String With Spaces in Java Using Scanner?](https://www.baeldung.com/java-scanner-input-with-spaces)
|
||||
- [What’s the difference between Scanner next() and nextLine() methods?](https://www.baeldung.com/java-scanner-next-vs-nextline)
|
||||
- [Handle NoSuchElementException When Reading a File Through Scanner](https://www.baeldung.com/java-scanner-nosuchelementexception-reading-file)
|
||||
- [Java Scanner](https://www.baeldung.com/java-scanner)
|
||||
- [Scanner nextLine() Method](https://www.baeldung.com/java-scanner-nextline)
|
||||
- [Java Scanner hasNext() vs. hasNextLine()](https://www.baeldung.com/java-scanner-hasnext-vs-hasnextline)
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>core-java-scanner</artifactId>
|
||||
<name>core-java-scanner</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>log4j-over-slf4j</artifactId>
|
||||
<version>${org.slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,11 +1,11 @@
|
|||
package com.baeldung.scannernextline;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Scanner;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ScannerNextLineUnitTest {
|
||||
|
|
@ -81,7 +81,6 @@
|
|||
<module>core-java-io-4</module>
|
||||
<module>core-java-io-apis</module>
|
||||
<module>core-java-io-apis-2</module>
|
||||
<module>core-java-io-apis-3</module>
|
||||
<module>core-java-io-conversions</module>
|
||||
<module>core-java-jar</module>
|
||||
<module>core-java-jndi</module>
|
||||
|
@ -125,6 +124,7 @@
|
|||
<module>core-java-properties</module>
|
||||
<module>core-java-reflection</module>
|
||||
<module>core-java-reflection-2</module>
|
||||
<module>core-java-scanner</module>
|
||||
<module>core-java-security-2</module>
|
||||
<module>core-java-security-3</module>
|
||||
<module>core-java-security-algorithms</module>
|
||||
|
|
Loading…
Reference in New Issue