-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenCurrentFile.java
More file actions
32 lines (26 loc) · 970 Bytes
/
OpenCurrentFile.java
File metadata and controls
32 lines (26 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.lang.Runtime;
import java.lang.Process;
import java.io.File;
import java.util.Scanner;
// opens the user mentioned source file in notepad++
class OpenCurrentFile {
public static void main(String []args) {
String appPath = "D:\\tools\\Notepad++\\notepad++.exe";
String a = "\\\\";
String b = "\\";
Scanner sc = new Scanner(System.in);
System.out.println("Enter a java File Name to open");
String fileName = sc.next();
File javaFile = new File(fileName+".java");
String javaFilePath = javaFile.getAbsolutePath();
String path = appPath+" "+javaFilePath;
Runtime runtime = Runtime.getRuntime();
String completePath = path.replace(b, a);
System.out.println(completePath);
try {
Process p = runtime.exec(completePath);
} catch(Exception err) {
System.out.println(err);
}
}
}