Created
August 28, 2018 19:35
-
-
Save mizanRahman/0bc0212c44be538a9694877183bd89e6 to your computer and use it in GitHub Desktop.
Unique Random Generation
This file contains hidden or 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
public class UniqueRandomNumberGeneratorImplV2 implements UniqueRandomNumberGenerator { | |
private SecureRandom random; | |
@Autowired | |
public UniqueRandomNumberGeneratorImplV2(SecureRandom random) { | |
this.random = random; | |
} | |
@Override | |
public String generateRandomUnique(int length) { | |
return IntStream.range(0, length) | |
.mapToObj(i -> String.valueOf(random.nextInt(10))) | |
.collect(Collectors.joining()); | |
} | |
} |
This file contains hidden or 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
private void writeTextToFile(String path, String content) throws IOException { | |
FileUtils.writeStringToFile(new File(path),content); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment