Moved get first and last 20 bytes to FileReaderWriter class.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package vslab1.src.Request.Data;
|
||||
|
||||
import vslab1.src.FileReaderWriter.FileReaderWriter;
|
||||
import vslab1.src.Peers.Peer;
|
||||
import vslab1.src.Sending.SendingQueue;
|
||||
import vslab1.src.Sending.Data.EDataType;
|
||||
@@ -24,16 +25,6 @@ public record SendFileReplyRequest(Peer sender, Peer receiver, String fileName,
|
||||
@Override
|
||||
public void execute(SendingQueue sendingQueue) {
|
||||
System.out.println(fileName);
|
||||
System.out.println(getFirstAndLast20Byte(fileContent));
|
||||
}
|
||||
|
||||
private String getFirstAndLast20Byte(String content) {
|
||||
if (content.length() > 40) {
|
||||
String first20Byte = content.substring(0, 20);
|
||||
String last20Byte = content.substring(content.length() - 20, content.length());
|
||||
return first20Byte + "...." + last20Byte;
|
||||
} else {
|
||||
return content;
|
||||
}
|
||||
System.out.println(FileReaderWriter.getFirstAndLast20Byte(fileContent));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user