SPARK-1182: File path for a URL bookmark is not working

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12036 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Konstantin Zolotarev
2011-02-26 06:16:31 +00:00
committed by konstantin.zolotarev
parent 6c93069ac1
commit 7480029f4c

View File

@ -1,36 +1,39 @@
/**
* $RCSfile: ,v $
* $Revision: $
* $Date: $
*
* Copyright (C) 2004-2010 Jive Software. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.spark.util;
import java.awt.Desktop;
import java.net.URI;
public class BrowserLauncher {
public static void openURL(String url) throws Exception {
if (url.startsWith("http") ||
url.startsWith("ftp")) {
Desktop.getDesktop().browse(new URI(url));
}
else {
Desktop.getDesktop().browse(new URI("http://" + url));
}
}
}
/**
* $RCSfile: ,v $
* $Revision: $
* $Date: $
*
* Copyright (C) 2004-2010 Jive Software. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.spark.util;
import java.awt.Desktop;
import java.net.URI;
public class BrowserLauncher {
public static void openURL(String url) throws Exception {
if (url.startsWith("http") || url.startsWith("ftp") || url.startsWith("file")) {
if (url.startsWith("file") && url.contains(" ")) {
url = url.replace(" ", "%20");
}
Desktop.getDesktop().browse(new URI(url));
} else {
Desktop.getDesktop().browse(new URI("http://" + url));
}
}
}