-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathController.java
152 lines (118 loc) · 4.37 KB
/
Controller.java
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mcmap;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
/**
*
* @author WRIM
*/
public class Controller extends Thread{
static int licznik = 0;
public static void runProcess(String command) {
if (0==0)return;
BufferedWriter outputWriter = null;
BufferedReader inputReader = null;
try {
Process process = Runtime.getRuntime().exec(command);
InputStream inputStream = process.getInputStream();
OutputStream outputStream = process.getOutputStream();
System.out.println("nazwa "+command);
outputWriter = new BufferedWriter(new OutputStreamWriter(
outputStream));
inputReader = new BufferedReader(new InputStreamReader(inputStream));
String line = null;
while ((line = inputReader.readLine()) != null) {
processLine(line);
}
} catch (IOException e)
{
System.out.println("nieudane otwieranie " + command);
}
finally {
try{
outputWriter.close();
inputReader.close();
}catch(Exception e){System.out.println("nieudane zamykanie "+command);}
}
}
private static void processLine(String line) {
System.out.println(++licznik + ": " + line);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws InterruptedException
{
File appdata = new File(System.getenv("APPDATA")+"");
if (System.getenv("APPDATA") == null)
{
appdata = new File(System.getProperty("user.home")+"");
}
File[] files = appdata.listFiles();
for (File file: files)
{
if (file.isDirectory())
System.out.println(file.getName());
}
new Window();
for (int i = 0; i < 0; i++) {
new Controller().start();
}
Thread.sleep(100);
runProcess("d:/dropbox/path/mcmap.exe");
Thread.sleep(100);
runProcess("d:\\dropbox\\komlogo\\comlogo.exe");
System.out.println(System.getenv("APPDATA"));
System.out.println(System.getProperty("user.home"));
System.out.println(System.getProperty("os.name"));
System.out.println(System.getProperties().toString().replace(',', '\n'));
System.out.println("--------------------------------------");
System.out.println(System.getenv().toString().replace(',', '\n'));
System.out.println(System.getProperty("user.language"));
System.out.println(System.getProperty("file.separator"));
}
public void run()
{
System.out.println("runnąłem się");
runProcess("d:\\dropbox\\path\\mcmap.exe c:\\users\\tomek\\appdata\\roaming\\.minecraft\\saves\\m -file testmcmapjava.png");
}
}
/*
public static void runProcess(String command) throws IOException {
BufferedWriter outputWriter = null;
BufferedReader inputReader = null;
try {
Process process = Runtime.getRuntime().exec(command);
InputStream inputStream = process.getInputStream();
OutputStream outputStream = process.getOutputStream();
outputWriter = new BufferedWriter(new OutputStreamWriter(
outputStream));
inputReader = new BufferedReader(new InputStreamReader(inputStream));
String line = null;
while ((line = inputReader.readLine()) != null) {
processLine(line);
}
} finally {
outputWriter.close();
inputReader.close();
}
}
private static void processLine(String line) {
System.out.println(line);
}
public static void main(String[] args) throws IOException {
System.out.println("");
runProcess("top -b -n 1");
}
*/