Compare commits
15 Commits
cd6100548c
...
fix/blocks
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ed8cdc792 | ||
|
|
23f5ff77ec | ||
|
|
ee7c2ba46b | ||
|
|
d0d239e0ca | ||
|
|
5fd53af017 | ||
|
|
48f4093906 | ||
|
|
0edbc24003 | ||
|
|
ecb1f7be3e | ||
|
|
66e4247199 | ||
|
|
1661e3e060 | ||
|
|
c086bcc2e6 | ||
|
|
68d7520e26 | ||
|
|
2c076c4c95 | ||
|
|
4d6e8b975f | ||
|
|
baab63f846 |
15
.gitignore
vendored
15
.gitignore
vendored
@@ -22,3 +22,18 @@
|
|||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
replay_pid*
|
replay_pid*
|
||||||
|
|
||||||
|
target/
|
||||||
|
*.class
|
||||||
|
.mtj.tmp/
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.ear
|
||||||
|
hs_err_pid*
|
||||||
|
|
||||||
|
# VS Code specific
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
.settings/
|
||||||
|
.vscode/
|
||||||
|
PKGBUILD
|
||||||
@@ -7,7 +7,7 @@ Small and lightweight image and iso flasher build on `dd`.
|
|||||||
[](https://en.wikipedia.org/wiki/Software_release_life_cycle#Beta)
|
[](https://en.wikipedia.org/wiki/Software_release_life_cycle#Beta)
|
||||||
|
|
||||||
# About
|
# About
|
||||||
Java program using `dd` to make flashing iso and image files easier on the terminal. This program allows anyone to flash iso and image files without having to search for extra GUI tools and by keeping it simple and resource-friendly.
|
Java program using `dd` to make flashing iso and image files easier on the terminal. This program allows anyone to flash iso and image files without having to search for extra GUI tools by keeping it simple and resource-friendly.
|
||||||
|
|
||||||
# Requirements
|
# Requirements
|
||||||
- `Java`: 21 (Download [here](https://www.oracle.com/java/technologies/downloads/#java21)
|
- `Java`: 21 (Download [here](https://www.oracle.com/java/technologies/downloads/#java21)
|
||||||
@@ -27,7 +27,7 @@ Java program using `dd` to make flashing iso and image files easier on the termi
|
|||||||
- **IMPORTANT**: Since dd needs sudo rights, ensure you have root priviliges.
|
- **IMPORTANT**: Since dd needs sudo rights, ensure you have root priviliges.
|
||||||
|
|
||||||
# Supported OS
|
# Supported OS
|
||||||
- Linux, MacOS, FreeBSD
|
- Linux
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
1. Clone the repository onto your local device.
|
1. Clone the repository onto your local device.
|
||||||
|
|||||||
55
pom.xml
Normal file
55
pom.xml
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
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>
|
||||||
|
|
||||||
|
<groupId>org.cametendo</groupId>
|
||||||
|
<artifactId>cflash</artifactId>
|
||||||
|
<version>1.0.1</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
|
<maven.compiler.target>21</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jline</groupId>
|
||||||
|
<artifactId>jline</artifactId>
|
||||||
|
<version>3.25.1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<version>3.6.0</version>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<mainClass>org.cametendo.Main</mainClass>
|
||||||
|
</manifest>
|
||||||
|
<manifestEntries>
|
||||||
|
<Enable-Native-Access>ALL-UNNAMED</Enable-Native-Access>
|
||||||
|
</manifestEntries>
|
||||||
|
</archive>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>make-assembly</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
31
src/main/java/org/cametendo/BlockSize.java
Normal file
31
src/main/java/org/cametendo/BlockSize.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package org.cametendo;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class BlockSize {
|
||||||
|
|
||||||
|
public static String blockSizeString = "4M";
|
||||||
|
|
||||||
|
public static String mapBlockSize(String input) {
|
||||||
|
return switch (input) {
|
||||||
|
case "1", "512K" -> "512K";
|
||||||
|
case "2", "1M" -> "1M";
|
||||||
|
case "3", "2M" -> "2M";
|
||||||
|
case "4", "4M" -> "4M";
|
||||||
|
case "5", "8M" -> "8M";
|
||||||
|
case "6", "16M" -> "16M";
|
||||||
|
default -> blockSizeString;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static String blockSize(Scanner UserInput) {
|
||||||
|
System.out.println("Choose a block size (Default: 4M)");
|
||||||
|
System.out.println("512KB (1), 1M (2), 2M (3), 4M (4), 8M (5), 16M (6)");
|
||||||
|
|
||||||
|
String input = UserInput.nextLine();
|
||||||
|
|
||||||
|
blockSizeString = mapBlockSize(input);
|
||||||
|
|
||||||
|
System.out.println("Using blocksize of: " + blockSizeString);
|
||||||
|
return blockSizeString;
|
||||||
|
}
|
||||||
|
}
|
||||||
28
src/main/java/org/cametendo/Dd.java
Normal file
28
src/main/java/org/cametendo/Dd.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package org.cametendo;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
public class Dd {
|
||||||
|
public static void dd() {
|
||||||
|
try {
|
||||||
|
ProcessBuilder pb = new ProcessBuilder("sudo", "dd", "if=" + FilePathAdd.ImagePath, "of=" + StorageDeviceLister.fullPath, "bs=" + BlockSize.blockSizeString, "status=progress", "oflag=" + OflagHandler.oflagHandleString);
|
||||||
|
pb.redirectErrorStream(true);
|
||||||
|
Process process = pb.start();
|
||||||
|
|
||||||
|
BufferedReader reader = new BufferedReader(
|
||||||
|
new InputStreamReader(process.getInputStream())
|
||||||
|
);
|
||||||
|
|
||||||
|
int character;
|
||||||
|
while ((character = reader.read()) != -1) {
|
||||||
|
char c = (char) character;
|
||||||
|
System.out.print(c);
|
||||||
|
System.out.flush();
|
||||||
|
}
|
||||||
|
OSDetector.wishWell(FilePathAdd.ImagePath);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
src/main/java/org/cametendo/FilePathAdd.java
Normal file
60
src/main/java/org/cametendo/FilePathAdd.java
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
package org.cametendo;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import org.jline.reader.LineReader;
|
||||||
|
import org.jline.reader.LineReaderBuilder;
|
||||||
|
import org.jline.reader.impl.completer.FileNameCompleter;
|
||||||
|
import org.jline.terminal.Terminal;
|
||||||
|
import org.jline.terminal.TerminalBuilder;
|
||||||
|
|
||||||
|
public class FilePathAdd {
|
||||||
|
|
||||||
|
public static String ImagePath = "";
|
||||||
|
|
||||||
|
protected static String filePath() throws IOException {
|
||||||
|
fileQuestion();
|
||||||
|
|
||||||
|
Terminal terminal = TerminalBuilder.terminal();
|
||||||
|
LineReader reader = LineReaderBuilder.builder().terminal(terminal).completer(new FileNameCompleter()).build();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
ImagePath = reader.readLine("Path: ").trim();
|
||||||
|
|
||||||
|
if (ImagePath.isBlank()) {
|
||||||
|
System.out.println("Oops... You didn't specify a file!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Path path = Path.of(ImagePath);
|
||||||
|
|
||||||
|
if (!Files.exists(path) || !Files.isRegularFile(path)) {
|
||||||
|
System.out.println("Invalid file! Please ensure the path points to an ISO / image file.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Using File: " + ImagePath);
|
||||||
|
return ImagePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String validateAndGetFile(String ImagePath) {
|
||||||
|
try {
|
||||||
|
Path path = Path.of(ImagePath);
|
||||||
|
if (Files.exists(path) && Files.isRegularFile(path)) {
|
||||||
|
return path.toRealPath().toString();
|
||||||
|
} else {
|
||||||
|
System.out.println("Invalid file! Please ensure the path points to an ISO / image file.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("File not found! Invalid Path or no access.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void fileQuestion() {
|
||||||
|
System.out.println("Please enter the FULL Path of your ISO / Image. (Tab-completion supported)");
|
||||||
|
}
|
||||||
|
}
|
||||||
23
src/main/java/org/cametendo/Flasher.java
Normal file
23
src/main/java/org/cametendo/Flasher.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package org.cametendo;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Flasher {
|
||||||
|
public static void flasher(Scanner UserInput) {
|
||||||
|
|
||||||
|
String input = "";
|
||||||
|
|
||||||
|
System.out.println("The program will use the following configuration, do you want to flash with this? (Y/n)");
|
||||||
|
System.out.println(" - To be flashed device: " + StorageDeviceLister.fullPath);
|
||||||
|
System.out.println(" - To be used path: " + FilePathAdd.ImagePath);
|
||||||
|
System.out.println(" - To be used blocksize: " + BlockSize.blockSizeString);
|
||||||
|
System.out.println(" - To be used oflag: " + OflagHandler.oflagHandleString);
|
||||||
|
input = UserInput.nextLine();
|
||||||
|
if (YesNo.check(input)) {
|
||||||
|
System.out.println("Starting to flash...");
|
||||||
|
} else {
|
||||||
|
System.out.println("Canceling...");
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
Dd.dd();
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/main/java/org/cametendo/Greeting.java
Normal file
18
src/main/java/org/cametendo/Greeting.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package org.cametendo;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Greeting {
|
||||||
|
public static void greeting(Scanner UserInput) {
|
||||||
|
System.out.println("Welcome to cflash!");
|
||||||
|
System.out.println("Would you like to flash an image (Y/n)");
|
||||||
|
String input = UserInput.nextLine();
|
||||||
|
if (YesNo.check(input)) {
|
||||||
|
System.out.println("Please choose the to be flashed device (f. e. sda)");
|
||||||
|
} else {
|
||||||
|
System.out.println("Canceling...");
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/main/java/org/cametendo/Main.java
Normal file
34
src/main/java/org/cametendo/Main.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package org.cametendo;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) throws InterruptedException, IOException {
|
||||||
|
Scanner UserInput = new Scanner(System.in);
|
||||||
|
if (args.length == 4) {
|
||||||
|
String validatedDevice = StorageDeviceLister.validateAndGetPath(args[0]);
|
||||||
|
if (validatedDevice == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String validatedFile = FilePathAdd.validateAndGetFile(args[1]);
|
||||||
|
if (validatedFile == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
StorageDeviceLister.fullPath = validatedDevice;
|
||||||
|
FilePathAdd.ImagePath = validatedFile;
|
||||||
|
BlockSize.blockSizeString = BlockSize.mapBlockSize(args[2]);
|
||||||
|
OflagHandler.oflagHandleString = OflagHandler.mapOflagHandle(args[3]);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Greeting.greeting(UserInput);
|
||||||
|
|
||||||
|
StorageDeviceLister.deviceCheck(UserInput);
|
||||||
|
FilePathAdd.filePath();
|
||||||
|
BlockSize.blockSize(UserInput);
|
||||||
|
OflagHandler.Oflag(UserInput);
|
||||||
|
}
|
||||||
|
Flasher.flasher(UserInput);
|
||||||
|
}
|
||||||
|
}
|
||||||
76
src/main/java/org/cametendo/OSDetector.java
Normal file
76
src/main/java/org/cametendo/OSDetector.java
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
package org.cametendo;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public class OSDetector {
|
||||||
|
|
||||||
|
public static void wishWell(String imagePath) {
|
||||||
|
String fileName = Path.of(imagePath).getFileName().toString().toLowerCase();
|
||||||
|
|
||||||
|
String osName;
|
||||||
|
|
||||||
|
// Specialized & Advanced Distros
|
||||||
|
if (fileName.contains("nyarch")) {
|
||||||
|
osName = "Nyarch Linux (Nyaa~!)";
|
||||||
|
} else if (fileName.contains("artix")) {
|
||||||
|
osName = "Artix Linux (Systemd-free Arch!)";
|
||||||
|
} else if (fileName.contains("gentoo")) {
|
||||||
|
osName = "Gentoo (Enjoy the compiling...)";
|
||||||
|
} else if (fileName.contains("nixos")) {
|
||||||
|
osName = "NixOS (Immutable & Reproducible!)";
|
||||||
|
} else if (fileName.contains("void")) {
|
||||||
|
osName = "Void Linux";
|
||||||
|
} else if (fileName.contains("arch")) {
|
||||||
|
osName = "Arch Linux (btw)";
|
||||||
|
} else if (fileName.contains("alpine")) {
|
||||||
|
osName = "Alpine Linux (Minimalism at its peak)";
|
||||||
|
} else if (fileName.contains("winux")) {
|
||||||
|
osName = "Winux (Windows without Windows)";
|
||||||
|
}
|
||||||
|
// Mainstream Linux
|
||||||
|
else if (fileName.contains("fedora")) {
|
||||||
|
osName = "Fedora (Freehat Linux)";
|
||||||
|
} else if (fileName.contains("debian")) {
|
||||||
|
osName = "Debian (Universal OS)";
|
||||||
|
} else if (fileName.contains("ubuntu")) {
|
||||||
|
osName = "Ubuntu (Debian but fancy)";
|
||||||
|
} else if (fileName.contains("mint")) {
|
||||||
|
osName = "Linux Mint";
|
||||||
|
} else if (fileName.contains("pop-os") || fileName.contains("pop_os")) {
|
||||||
|
osName = "Pop!_OS";
|
||||||
|
}
|
||||||
|
// The BSD Family
|
||||||
|
else if (fileName.contains("freebsd")) {
|
||||||
|
osName = "FreeBSD";
|
||||||
|
} else if (fileName.contains("openbsd")) {
|
||||||
|
osName = "OpenBSD (Secure by default)";
|
||||||
|
} else if (fileName.contains("netbsd")) {
|
||||||
|
osName = "NetBSD (It runs on everything!)";
|
||||||
|
}
|
||||||
|
// Security & Privacy
|
||||||
|
else if (fileName.contains("kali")) {
|
||||||
|
osName = "Kali Linux (Happy Hacking)";
|
||||||
|
} else if (fileName.contains("tails")) {
|
||||||
|
osName = "Tails (Incognito mode: ON)";
|
||||||
|
} else if (fileName.contains("qubes")) {
|
||||||
|
osName = "Qubes OS (Security by Compartmentalization)";
|
||||||
|
}
|
||||||
|
// Others & Legacy
|
||||||
|
else if (fileName.contains("win") && (fileName.contains("10") || fileName.contains("11"))) {
|
||||||
|
osName = "Windows (Spies... Spies everywhere)";
|
||||||
|
} else if (fileName.contains("haiku")) {
|
||||||
|
osName = "Haiku OS";
|
||||||
|
} else if (fileName.contains("reactos")) {
|
||||||
|
osName = "ReactOS";
|
||||||
|
}
|
||||||
|
// Generic Fallbacks
|
||||||
|
else if (fileName.contains("linux")) {
|
||||||
|
osName = "Linux";
|
||||||
|
} else if (fileName.contains("bsd")) {
|
||||||
|
osName = "BSD";
|
||||||
|
} else {
|
||||||
|
osName = "new OS";
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("\nFlash complete! Have fun with your " + osName + " installation! 🚀");
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/main/java/org/cametendo/OflagHandler.java
Normal file
29
src/main/java/org/cametendo/OflagHandler.java
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package org.cametendo;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class OflagHandler {
|
||||||
|
|
||||||
|
public static String oflagHandleString = "direct";
|
||||||
|
|
||||||
|
public static String mapOflagHandle(String input) {
|
||||||
|
return switch (input) {
|
||||||
|
case "1", "direct" -> "direct";
|
||||||
|
case "2", "dsync" -> "dsync";
|
||||||
|
case "3", "sync" -> "sync";
|
||||||
|
case "4", "nocache" -> "nocache";
|
||||||
|
default -> oflagHandleString;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static String Oflag(Scanner UserInput) {
|
||||||
|
System.out.println("Choose an Oflag (Default: direct)");
|
||||||
|
System.out.println("direct (1), dsync (2), sync (3), nocache (4)");
|
||||||
|
|
||||||
|
String input = UserInput.nextLine();
|
||||||
|
|
||||||
|
oflagHandleString = mapOflagHandle(input);
|
||||||
|
|
||||||
|
System.out.println("Using Oflag: " + oflagHandleString);
|
||||||
|
return oflagHandleString;
|
||||||
|
}
|
||||||
|
}
|
||||||
62
src/main/java/org/cametendo/StorageDeviceLister.java
Normal file
62
src/main/java/org/cametendo/StorageDeviceLister.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package org.cametendo;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class StorageDeviceLister {
|
||||||
|
|
||||||
|
public static String device = "";
|
||||||
|
public static String fullPath = "";
|
||||||
|
|
||||||
|
protected static String deviceCheck(Scanner UserInput) {
|
||||||
|
deviceList();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
device = UserInput.nextLine();
|
||||||
|
if (device.isBlank()) {
|
||||||
|
System.out.println("Oops... Device name is empty. Did you missclick?");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Path path = Path.of("/dev/" + device);
|
||||||
|
|
||||||
|
try {
|
||||||
|
fullPath = path.toRealPath().toString();
|
||||||
|
|
||||||
|
System.out.println("Using device: " + fullPath);
|
||||||
|
return fullPath;
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Failed to access device! Invalid path or no access. Please try again.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String validateAndGetPath(String deviceName) {
|
||||||
|
try {
|
||||||
|
Path path = Path.of("/dev/" + deviceName);
|
||||||
|
return path.toRealPath().toString();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Device not found. Invalid Path or no access.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void deviceList() {
|
||||||
|
try {
|
||||||
|
ProcessBuilder pb = new ProcessBuilder("lsblk");
|
||||||
|
Process process = pb.start();
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
System.out.println(line);
|
||||||
|
}
|
||||||
|
process.waitFor();
|
||||||
|
System.out.println("Please enter the name of your device (without /dev/):");
|
||||||
|
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/main/java/org/cametendo/YesNo.java
Normal file
17
src/main/java/org/cametendo/YesNo.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package org.cametendo;
|
||||||
|
public class YesNo {
|
||||||
|
public static boolean check(String input) {
|
||||||
|
switch (input) {
|
||||||
|
case "Y":
|
||||||
|
return true;
|
||||||
|
case "y":
|
||||||
|
return true;
|
||||||
|
case "":
|
||||||
|
return true;
|
||||||
|
case "n":
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user