import java.awt.Desktop;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URI;
import javax.swing.JFileChooser;
public class UrlsOpener {
public static void main(String[] args) {
openAllURLs();
}
private static void openAllURLs() {
try {
final JFileChooser fc = new JFileChooser();
int returnVal = fc.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
if (file != null && file.exists()) {
FileReader frd = new FileReader(file);
BufferedReader brd = new BufferedReader(frd);
String url = null;
while ((url = brd.readLine()) != null) {
openURL(url);
}
brd.close();
frd.close();
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
private static void openURL(String urlText) {
if (Desktop.isDesktopSupported()) {
URI uri = URI.create(urlText);
try {
Desktop.getDesktop().browse(uri);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Subscribe to:
Post Comments (Atom)
How to close that tabs? Thanks !!!
ReplyDelete