B
Bumsys
How can I get shared folders of other computer in the network?
I do so:
public static String[] listSharedFolders(final String compName) {
ArrayList retValue = new ArrayList();
retValue.add("");
try {
File temp = File.createTempFile("N2AU", ".txt");
String filename = temp.getAbsolutePath();
String cmd = "cmd /c net view " + compName + " > " +
filename;
Process process = Runtime.getRuntime().exec(cmd);
process.waitFor();
BufferedReader bfr = new BufferedReader(new
FileReader(temp));
String text;
ArrayList lines = new ArrayList();
while ((text = bfr.readLine()) != null) {
lines.add(text);
}
bfr.close();
temp.delete();
ArrayList list = new ArrayList();
for (int i = 0; i < lines.size(); i++) {
String line = (String) lines.get(i);
StringTokenizer sttk = new StringTokenizer(line);
while (sttk.hasMoreTokens()) {
String comp = sttk.nextToken();
list.add(comp);
}
}
while (list.contains("Disk")) {
int index = list.indexOf("Disk");
retValue.add(list.get(index - 1));
list.remove(index);
}
} catch (IOException e) {
log.error("Error", e);
} catch (InterruptedException e) {
log.error("Error", e);
}
return (String[]) retValue.toArray(new String[] {});
}
But in various windows(english, russian, german) type of folders is
written various.
english: Disk
russian: äÉÓË
How can I get shared folder of other computer in the network?
I do so:
public static String[] listSharedFolders(final String compName) {
ArrayList retValue = new ArrayList();
retValue.add("");
try {
File temp = File.createTempFile("N2AU", ".txt");
String filename = temp.getAbsolutePath();
String cmd = "cmd /c net view " + compName + " > " +
filename;
Process process = Runtime.getRuntime().exec(cmd);
process.waitFor();
BufferedReader bfr = new BufferedReader(new
FileReader(temp));
String text;
ArrayList lines = new ArrayList();
while ((text = bfr.readLine()) != null) {
lines.add(text);
}
bfr.close();
temp.delete();
ArrayList list = new ArrayList();
for (int i = 0; i < lines.size(); i++) {
String line = (String) lines.get(i);
StringTokenizer sttk = new StringTokenizer(line);
while (sttk.hasMoreTokens()) {
String comp = sttk.nextToken();
list.add(comp);
}
}
while (list.contains("Disk")) {
int index = list.indexOf("Disk");
retValue.add(list.get(index - 1));
list.remove(index);
}
} catch (IOException e) {
log.error("Error", e);
} catch (InterruptedException e) {
log.error("Error", e);
}
return (String[]) retValue.toArray(new String[] {});
}
But in various windows(english, russian, german) type of folders is
written various.
english: Disk
russian: äÉÓË
How can I get shared folder of other computer in the network?