I want to write a program that every time a new device is mounted, it automatically unmounts and reformats it in ext4. I'm working on creating a solution for detecting mounting from someone else's question, but I still don't know how to get a tab input. I need it because every SD card will have a different name, so maybe if there's a different way to do that without using tab that'd be fine as well. This will be used in ubuntu 18.04.1.
package ReformatSDs;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ReformatSDs
{
public static void main(String[] args) throws IOException, InterruptedException
{
String command = "umount /media/dev/xxxx-xxxx";//this is where I need the tab input to replace the xxxx-xxxx
String command2 = "sudo mkfs.ext4 /dev/mmcblk2p1";
Process proc = Runtime.getRuntime().exec(command);
Process proc2 = Runtime.getRuntime().exec(command2);
BufferedReader reader =
new BufferedReader(new InputStreamReader(proc.getInputStream()));
BufferedReader reader2 =
new BufferedReader(new InputStreamReader(proc3.getInputStream()));
String line = "";
while((line = reader.readLine()) != null) {
System.out.print(line + "\n");
}
proc.waitFor();
}
}`