Четверг, 20 Мая 2010 г. 11:13
+ в цитатник
требовалось из java открывать файлы в linux
package javaapplication1;
import java.io.File;
import java.io.FileWriter;
/**
*
* @author igor
*/
public class xdgopen {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Runtime r = Runtime.getRuntime();
Process p = null;
try {
String text= "xdg-open '/home/igor/f 1 1 1.txt'";
File file = new File("/home/igor/runas");
if(file.exists())
file.delete();
file.createNewFile();
file.setExecutable(true);
FileWriter os = new FileWriter(file);
os.write(text);
os.close();
p = r.exec("/home/igor/runas") ;
} catch (Exception e) {
System.out.println(p.getErrorStream());
System.out.println("Error executing notepad.");
}
}
}
[/mode]
Метки:
java open file linux xdg-open
-
Запись понравилась
-
0
Процитировали
-
0
Сохранили
-