Last active
July 13, 2020 04:29
-
-
Save h1ddengames/4c82ffee1f3ed32d5fd3783e320c3a2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class Tools { | |
public void combineFiles(File fileInput, File fileOutput) throws IOException { | |
BufferedWriter writer = new BufferedWriter(new FileWriter(fileOutput)); | |
BufferedReader reader = new BufferedReader(new FileReader(fileInput)); | |
String line; | |
while ((line = reader.readLine()) != null) { | |
writer.write(line + "\n"); | |
} | |
writer.close(); | |
reader.close(); | |
} | |
public int findNumberFromString(String str) { | |
Pattern p = Pattern.compile("\\d+"); // Defines a pattern to search a string for only numbers. | |
Matcher m = p.matcher(str); // Find the numbers in a given string using the searching pattern. | |
if(m.find()) { | |
return Integer.parseInt(m.group()); | |
} | |
return Integer.MIN_VALUE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment