Created
March 10, 2025 19:49
-
-
Save aerodame/2259f0548fbd62d3c5609338dc29637e to your computer and use it in GitHub Desktop.
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 static void createFileWithPhrase(String filename, String phrase) { | |
File file = new File(filename); | |
try (RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw")) { | |
randomAccessFile.write(phrase.getBytes()); // Write the string as bytes. | |
System.out.println("File " + filename + " created with the phrase: \"" + phrase + "\""); | |
} catch (IOException e) { | |
System.err.println("Error creating file: " + e.getMessage()); | |
} | |
} | |
static class FileRegionTask implements Runnable { | |
private final String filename; | |
private final long startPosition; | |
private final long regionSize; | |
private final String threadName; | |
public FileRegionTask(String filename, long startPosition, long regionSize, String threadName) { | |
this.filename = filename; | |
this.startPosition = startPosition; | |
this.regionSize = regionSize; | |
this.threadName = threadName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment