I'm porting parts of Java project to C# and came across this constant Constant.NamespaceSpecNS.
One of its uses is in the following Java context:
_xmlElement.setAttributeNS(Constants.NamespaceSpecNS,"a_qualified_name", "some_value");
where seAttributesNS is declared in org.w3c.dom Interface Element.
So, ... |
I got this error message :
java.net.URISyntaxException: Illegal character in query at index 31: http://finance.yahoo.com/q/h?s=^IXIC
My_Url = http://finance.yahoo.com/q/h?s=^IXIC
When I copied it into a browser address field, it showed the correct page, it's a ...
|
A quick Google didn't turn up a definitive answer. If URI does do this, is there a widespread third-party library that won't do this? I just need some parsing, and I ... |
Is there any way in Java to print to a specific IPP printer? All of the sample code and tutorials I've found focus on how to print a particular type of ... |
I'm trying to parse the following URI : http://translate.google.com/#zh-CN|en|?
but got this error message :
java.net.URISyntaxException: Illegal character in fragment at index 34: http://translate.google.com/#zh-CN|en|?
...
|
An application I'm working on involves accessing files on network file shares, and we're using URIs to specify the files' locations.
My understanding of the file: URI is that they should take ... |
I am just starting to look at Jain Sip and I was wondering how to create a SipUri that only contains the ip address and does not contain the user and ... |
|
I am looking for a java library/class to parse clean URL's and get all the properties like query, port, host , domain, subdomain etc. Essentially most of the functionality that java.net.URI ... |
In Java can I create a URI for a file located locally in the hard drive? If so, how should it be constructed?
|
I'm trying to resolve two URIs, but it's not as straightforward as I'd like it to be.
URI a = new URI("http://www.foo.com");
URI b = new URI("bar.html");
The trouble is that a.resolve(b).toString() is now ... |
I need to create a custom URI scheme for my project.
i.e
urn:myprotocol:{p1}:{p2}:{p3}:{p4} - opaque representation
myprotocol://{p1}/{p2}/{p3}/{p4} - hierarchical representation.
How can I add my scheme to Java URI class? Or, how can I ... |
I need to get a file object online, and I know the file is located at : http://nmjava.com/Dir_App_IDs/Dir_GlassPaneDemo/GlassPaneDemo_2010_04_06_15_00_SNGRGLJAMX
If I paste it into my browser's url, I'll be able to ... |
Solution
Okay I found 1 solution on Stackoverflow after a little more searching but I hope to do it with no extra libraries. http://stackoverflow.com/questions/2230676/how-to-check-for-a-valid-url-in-java/2230770#2230770
My problem:
First of hopefully this is not a ... |
I need to decode a URI that contains a query string; expected input/output behavior is something like the following:
abstract class URIParser
{
...
|
Is there a better way to get a copy (clone) of a URI than this horrible hack?
import org.eclipse.emf.common.util.URI;
URI cloned = URI.createURI( originalURI.toString() );
Thanks in advance!
|
I am new to XSL, and thus new to using scripts within the XSL.
I have taken example code (also using C#) and adapted it for my own use.. but it does ... |
Assuming I am given a URI, and I want to find the file extension of the file that is returned, what do I have to do in Java.
For example the file ... |
I am doing the following:
String url = String.format(WEBSERVICE_WITH_CITYSTATE, cityName, stateName);
String urlUtf8 = new String(url.getBytes(), "UTF8");
Log.d(TAG, "URL: [" + urlUtf8 + "]");
Reader reader = WebService.queryApi(url);
The output that I am looking for is ... |
I have a URI string like the following:
http://www.christlichepartei%F6sterreichs.at/steiermark/
I'm creating a java.lang.URI instance with this string and it succeeds but when I want to retrieve the host it ... |
In a particular program, I am passed a file: URL and I need to convert it to a URI object. Using the toURI method will throw a java.net.URISyntaxException if there ... |
I'm validating an XML file using Xerces and haven all the schema files locally in my classpath (using an XML catalog).
Validator validator = schema.newValidator();
validator.setResourceResolver(CatalogResourceResolver.getInstance());
validator.validate(getSource(true));
(getSource(boolean) gets ... |
After seeing quite some more cryptic error message, I realize they may be due to bogus URIs present here:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
...
|
Having trouble setting up a URL connection with Chinese characters in the URL. It works with Latin characters:
String xstr = "???????????" ;
URI uri = new URI("http","ajax.googleapis.com","/ajax/services/language/detect","v=1.0&q="+xstr,null);
URL url = ...
|
I know this has probably been asked 10000 times, however, I can't seem to find a straight answer to the question.
I have a LOB stored in my db that represents ... |
I am currently using Cobra: Java HTML Renderer & Parser to render an HTML page that is dynamically generated based on user choices in a java app.
In my app the ... |
I am using the Collection() Function in a XSL Vers 2.0 and apply the transform in Java using Saxon.
When I am on mac os i'm passing a parmater through the saxon ... |
I have several strings that are being combined to make a URI. I want to ensure that the resulting URI is as simple as possible. For example, given
str1 = "/dir1/dir2";
str2 ...
|
unexpected element (uri:"", local:"Group"). Expected elements are <{}group>
Meet an exception when unmarshalling from xml
JAXBContext jc = JAXBContext.newInstance(Group.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
Group group = (User)unmarshaller.unmarshal(new File("group.xml"));
Group class has no any annotation and ... |
HI guys,
I have a URL and I want to embed it in the body of a mailto. Till now, I've tried 2 methods to encode the URL and both of ... |
I'm working on a live video Java application, and have run into the common problem of NAT traversal - two computers can connect to each other on local network, but not ... |
I am using the following code to show NSE indices in default browser.
String downloadURL = "http://in.finance.yahoo.com/q;_ylt=AkieA" +
"_4_rXXRBh2SH7_U3kXyULlG;_ylu=X3oDMTE1Nmc5cjBnBHBvcwMyBHNlY" +
"wNmb290ZXIteWZpbmFuY2UEc2xrA25pZnR5NTA-?s=^NSEI";
java.awt.Desktop myNewBrowserDesktop = java.awt.Desktop.getDesktop();
java.net.URI myNewLocation = new java.net.URI(downloadURL);
myNewBrowserDesktop.browse(myNewLocation);
The ... |
Suppose we have a string "http://www.example.com/feed". I am breaking this string up into three pieces for use with Apache's URI class:
1. "http"
2. "www.example.com"
3. "/feed"
Is there a proper term ... |
Is this behavior intentional?
//create the same URI using two different constructors
URI foo = null, bar = null;
try {
//constructor: URI(uri string)
foo = new ...
|
I'm looking for a way to launch my java application when using a custom URI.
Something in the lines of
movie://superman/
This should start my application and display information about the movie "Superman".
if friends ... |
I was searching code that I can use to read XML file. and I did find one as below. But my problem is, I'm unable to read a XML file online. ... |
I'm trying to read an XML file using java. I can sucessfully read the file but the problem is, I don't know how to read the values inside the ... |
I'm trying to construct a java.net.URI with illegal characters as the server is a piece of old hardware, not being able to decode RFC-2396 complients URIs. This server demands a http-get ... |
I have a servlet filter in my Java app to ensure that users are using up-to-date URI for articles and categories. The problem is, that according to the profiler results this ... |
I have created a graphical image with the following sample code.
BufferedImage bi = new BufferedImage(50,50,BufferedImage.TYPE_BYTE_BINARY);
Graphics2D g2d = bi.createGraphics();
// Draw graphics.
g2d.dispose();
// BufferedImage now has my image I want.
At this point ... |
let's say I have a file located in:
http://example.com/123.app
now I get the file name using the following (u is an entire url string):
String fileName = u.substring( u.lastIndexOf('/')+1, u.length() );
but I want to ... |
In Java, the URI class is immutable.
Here's how I'm currently modifying the port:
public URI setUriPort(URI uri,int port)
{
try {
URI newUri ...
|
In an Apache Camel route, I want to take several headers and compose them into an HTTP query string in a safe way. The only examples I've found either use constant(), ... |
source.xml:
<?xml version="1.0" encoding="UTF-8"?>
<zip:archive xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" xmlns:zip="com.test.zip">
<zip:entry zip:target="test1.xml"><manifest:manifest>aaa</manifest:manifest></zip:entry>
<zip:entry zip:target="test2.xml">.......</zip:entry>
</zip:archive>
I use javax.xml.stream.XMLStreamReader to read source.xml file, do some action, and then write to disk according to the attribute value of zip:target.
the result file, test1.xml:
<?xml ...
|
import java.net.*;
public class TestURI {
public static void main(String args[]) throws URISyntaxException
{
String first = ...
|
We are trying to redirect bin-ends2 to wines.jsp with a number of parameters passed over to the application server. Apache is stripping the parameters off and so the application server fdoes ... |
In Java, is there a way that we can generate URI at run-time for a data in memory?
I am looking for an example like the following:
String myContent ...
|
'Long time reader, first time poster' here.
I'm in the process of making a bot for a spanish Wiki I administer. I wanted to make it from scratch, since one ... |
One way that Steam lets users launch games and perform many other operations, is by using URI protocols, for example (from Valve developer community):
steam://run/<id> will launch the game that ... |
I am receiving the following error when trying to access font file :
011.08.31 12:12:42.704 ERROR [PDFOutputHandler] - Unable to resolve Unicode font
java.lang.IllegalArgumentException: URI scheme is not "file"
at java.io.File.<init>(File.java:366)
at com.xx.reports.output.handler.PDFOutputHandler.addUnicodeFont(PDFOutputHandler.java:393)
at com.xx.reports.output.handler.PDFOutputHandler.renderOutput(PDFOutputHandler.java:104)
at com.xx.reports.output.handler.PDFOutputHandler.renderOutput(PDFOutputHandler.java:134)
at ...
|
I've tried to use java.net.URI to manipulate query strings but I failed to even on very simple task like getting the query string from one url and placing it in another.
Do ... |
I need a map in which I store ID (key) and hostname:port (value). What type of object should I use to store the value?
I tried something like this:
map.put(id, new URI("localhost:2222"));
But ... |
The documentation for java.net.URI specifies that
For any URI u that ... and that does not encode characters except those that must be quoted, the following identities also ... |
I need to create a java URL object by providing a representation containing a delimiter, which is excluded for US_ASCII Characters. You can find the speicification here 2.4.3. Excluded ... |
How do i convert String www.mywebsite.com/firefox.txt to URL ? I wanted to use this in the file object and then into the FileReader constructor.
|
I am trying to extract an XML node from a URI reference. This URI reference is generated by an XAdES4j signer, and could reference a node within the same XML file, ... |
I'm new to apache-camel and know i met a problem.
I want to use simple expressions in my uri definition, but i don't know how.
For example:
from("foo://bar").to("foo://bar?var=${header.varName}");
Is there a way to use such ... |
I have several services that I would like to add Camel routes. The examples in xml I see are like so:
<route id="myId"
from uri="direct:inside"/>
to uri="mock:inside"/>
</route>
Where can I find the acceptable values ... |
We've implemented an HTTP authentication connection, encoded in C# with Uri.EscapeDataString().
I'm trying to make an identical java test application that does the exact same thing as the C# version, but URLEncoder.encode(string, ... |
Well here is how w3.org explains it: URI Uniform Resource Identifier. The generic set of all names/addresses that are short strings that refer to resources. URL Uniform Resource Locator. An informal term (no longer used in technical specifications) associated with popular URI schemes: http, ftp, mailto, etc. URN Uniform Resource Name. An URI that has an institutional commitment to persistence, availability, ... |
60. URI coderanch.comSometimes it takes more than "plain English" to explain some concepts, but I shall try: You know what a URL (Uniform Resource Locator) is, right? It's what you type into the address bar of a web browser to bring up a web page (i.e. www.javaranch.com). That's one kind of URI. If you have a URL you know exactly where on the ... |
The ServletContext is a means by which the servlet can communicate with the servlet container. From the API:public interface ServletContext Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file. There is one context per "web application" per ... |
62. uri map coderanch.com |
|
|
Interesting happening I had with my servlet and was wondering if anyone can explain it? I'm using the JAXP SaxParser in a servlet to read a config XML document for the servlet for service rendering. Funny thing is that the SaxParser has a parse() method that can either take a File object or a String uri object plus the handler and ... |
|
|
|
I'm using HttpServletRequest.getRequestURI(), because I need this simple form (from javadoc): First line of HTTP request Returned Value POST /some/path.html HTTP/1.1/some/path.html GET http://foo.bar/a.html HTTP/1.0 /a.html HEAD /xyz?a=b HTTP/1.1/xyz Unfortunately, "The web container does not decode this String", which leaves me with things like /foo%20bar.html when I call it. I need a clean way to decode the URI that is returned (or ... |
I'm not sure anyone really hit this on the head so far... A URL is, as given earlier, a Uniform Resource Locator - it's what we colloquially call a "web address" and defines the host name and port of a server and the path to a resource on that server (including any extra query string data). A URI is the general ... |
|
|
paul thanks for your reply. Does this mean "file://\\server1\\directory1" is incorrect or we cannot use URI in the send redirect. I am using this to redirect users to open a windows folder and let them paste documents. when I paste the above uri in the explorer directly it opens the folder, but thru the application it does not. can you suggest ... |
Hi all, Java packages usually follow format of usuing reverse domain names e.g. developers working for a company www.google.com would put their classes in a package com.google.www.engine etc.... I am wondering if anybody has some code or knows of a library (I took a look at Apache commons but didnt find anything there) in where I might get some code that ... |
|
|
|
|
Hi, I'm trying to figure out how to use this constructor of File class which takes a URI as an argument. I tried searching in Google and tried a few ways of putting a uri in its constructor, but it's not working. What I want to do is create a text file on my computer, through web browser, using a Servlet. ... |
import java.io.File; import java.net.URI; import java.net.URISyntaxException; class TestURI { public static void main(String[] args) { try{ URI base = new URI("http://markmail.org/message/2q3cywpmdpjjkm4l"); System.out.println("Base: " + base.toString()); File myDir=new File(base); System.out.println(myDir.getAbsolutePath() + (myDir.isDirectory() ? " is" : " is not") + " a directory."); if(myDir.isDirectory()){ String[] str=myDir.list(); for(String s:str) { System.out.println(s); }} }catch(URISyntaxException e){ System.out.println(e);} } } |
Hello, I am trying to create a file with a URI.Following is a piece of code that I am using: URI uri = new URI("http://146.45.2.44/downloads/materials/bcc.txt"); File test = new File(uri); When I try to create a new File using the 2nd line,I get an exception which says "URI scheme is not "file". I intend to use this URI to locate files ... |
|
Hi! I'm trying to write a script that transfers a photo from a Facebook album to a Picasa album. I'm using the following code: URL fileURL = new URL("http://www.facebook.com/karstenda/pic.jpg"); URI fileURI = new URI(fileURL.toString()); uploadToPicasa(new File(fileURI)); The part : "new File(fileURI)" crashes and gives the following exception: Caused by: java.lang.IllegalArgumentException: URI scheme is not "file" at java.io.File.(File.java:366) It seems that the ... |
|
I have designed one Java application in which I have provided a button. On pressing that button, following method is invoked and mail window is opened in ms-outlook on widows. But it throws exception on ubuntu thunderbird. public static void onLaunchMail(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_onLaunchMail String mailTo = "user@domain.com"; URI uriMailTo = null; try { if (mailTo.length() >0) { uriMailTo = new ... |
Keith, Thanks for your suggestion. What I'm trying to do is to get a list of the classes in a package. The package is in a .Jar and the .Jar can be anywhere on the user's system. I have used the URI method to get the full path of the package, because its location will not change within the .Jar. The ... |
You cant do it becouse the URI is pointing to a file in the internet and you cant simply open it and write but if you want you can get its last part (FileName) and create a file with the same name in one of your folders but still the url may not have a valid file name at the end ... |
- When I use this for my program. I have placed the webwork file inside my root folder but it stills showing the error. Error :- org.apache.jasper.JasperException: File "/LeaveApp/Index/webwork" not found org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116) org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:160) org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:424) org.apache.jasper.compiler.Parser.parseDirective(Parser.java:493) org.apache.jasper.compiler.Parser.parseElements(Parser.java:1557) org.apache.jasper.compiler.Parser.parse(Parser.java:127) org.apache.jasper.compiler.ParserController.doParse(ParserController.java:212) org.apache.jasper.compiler.ParserController.parse(ParserController.java:101) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:156) org.apache.jasper.compiler.Compiler.compile(Compiler.java:296) org.apache.jasper.compiler.Compiler.compile(Compiler.java:277) org.apache.jasper.compiler.Compiler.compile(Compiler.java:265) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) Please help to validate. |
I have a connection to a server which returns infrmation to my in-stream which is UTF8 "percent escaped". For example the following string could be returned : "album%3A2%20-%204%20-%20the%20Bass%20(Disc%201)" I am looking for a standard way of decoding this string, e.g replacing "%3A" with ":", "%20" with " " and so on. The only info I can find on this seems to ... |
Srinivas_reddy wrote: can one clarify this what is the diff between URL & URI one basic difference i know is URL includes the domain name were as URI includes only path That one is plain wrong. First of all: here are the Wikipedia articles: [URI|http://en.wikipedia.org/wiki/URI] and [URL|http://en.wikipedia.org/wiki/URL]. Use them for reference. * Every URL is a URI. * Not every URI ... |
|
It gives the same InvocationTargetException error when it should be a simple NullPointerException. I have been using DrJava for years and never this problem. I tried the same code on the latest stable version of DrJava, and that time it worked right. So there must be something wrong with the latest DrJava beta. |
Maybe you could have given up one step earlier then and spared me your arrogance instead of giving no advice or insight at all? You did nothing to help so far, you complain that I cannot think of another way to solve my problem when I came here exactly to ask about advice how to solve this problem in another way. ... |
|
|
Hello all, I am having a slight problem wrapping my jar as an exe using launch4j and was wondering if anyone could offer assistance. If this is the wrong place for this, please direct me somewhere that is appropriate. I have a program that runs fine from netbeans / ant / command line. However, when I wrap it in an exe ... |
|
|
Several ways to do it. You could write the file and then use sftp or scp or some other protocol to move the file to the server. What are you actually trying to achieve? If the server will always be at local host, you can just write the file directly to the directory (note: directories and URLs are not the same ... |
That PDF file you want to "open" is that located in your jar? If so, I believe Desktop.open(File) cannot be used to do that. Another way to go about this would be to copy the PDF from your jar into a temporary file on the computer and use Desktop.open(File) to open the temporary file. |