Created
June 4, 2023 16:05
-
-
Save R3DHULK/8dc2c79af486d554220f791bd5d0e8bb to your computer and use it in GitHub Desktop.
Forensic Data Recovery App Written In Java
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
import javax.swing.*; | |
import java.awt.*; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import java.io.*; | |
public class ForensicDataRecoveryApp extends JFrame { | |
private JButton selectButton; | |
private JButton recoverButton; | |
private JTextArea logTextArea; | |
private File selectedFile; | |
public ForensicDataRecoveryApp() { | |
setTitle("Forensic Data Recovery App"); | |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
setSize(400, 300); | |
setLayout(new FlowLayout()); | |
selectButton = new JButton("Select File"); | |
selectButton.addActionListener(new ActionListener() { | |
@Override | |
public void actionPerformed(ActionEvent e) { | |
selectFile(); | |
} | |
}); | |
add(selectButton); | |
recoverButton = new JButton("Recover Text"); | |
recoverButton.addActionListener(new ActionListener() { | |
@Override | |
public void actionPerformed(ActionEvent e) { | |
recoverText(); | |
} | |
}); | |
recoverButton.setEnabled(false); | |
add(recoverButton); | |
logTextArea = new JTextArea(10, 30); | |
logTextArea.setEditable(false); | |
add(new JScrollPane(logTextArea)); | |
setVisible(true); | |
} | |
private void selectFile() { | |
JFileChooser fileChooser = new JFileChooser(); | |
int result = fileChooser.showOpenDialog(this); | |
if (result == JFileChooser.APPROVE_OPTION) { | |
selectedFile = fileChooser.getSelectedFile(); | |
recoverButton.setEnabled(true); | |
log("Selected file: " + selectedFile.getAbsolutePath()); | |
} | |
} | |
private void recoverText() { | |
if (selectedFile != null) { | |
StringBuilder recoveredText = new StringBuilder(); | |
try (BufferedReader reader = new BufferedReader(new FileReader(selectedFile))) { | |
String line; | |
while ((line = reader.readLine()) != null) { | |
// Modify the text recovery logic based on your specific requirements | |
String recoveredLine = recoverModifiedText(line); | |
recoveredText.append(recoveredLine).append("\n"); | |
} | |
log("Text recovery complete."); | |
log("Recovered text:\n" + recoveredText.toString()); | |
} catch (IOException e) { | |
log("Failed to recover text: " + e.getMessage()); | |
} | |
} | |
} | |
// Modify this method to implement your text recovery logic | |
private String recoverModifiedText(String line) { | |
// Example: Reverse the line | |
return new StringBuilder(line).reverse().toString(); | |
} | |
private void log(String message) { | |
logTextArea.append(message + "\n"); | |
} | |
public static void main(String[] args) { | |
SwingUtilities.invokeLater(new Runnable() { | |
public void run() { | |
new ForensicDataRecoveryApp(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment