Andrew Carney

Ranch Hand
+ Follow
since Oct 17, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Andrew Carney

Hi,

I think I know what is causing me this problem although still don't know how to fix it.

I wanted to keep my question simple so probably should have mentioned that the file is going through an object of type org.springframework.web.multipart.MultipartFile first (I am doing this through a Spring MVC application).
It looks like that MultipartFile is being too smart and is stripping the xml tags from the file, leaving me with just the values. I have tried with a couple of coding options and I always get the same result - From a simple standalone java application I get the content of the file correctly however when reading it through a MultipartFile object it strips the tags out. I have posted this in the springsource forum and hopefully someone will be able to help there.
12 years ago
Hello

I am using the below code in order to read a file and convert it into a String.
When I read a text file it is fine however when i'm reading an xml file all I'm getting are the values of the XML attributes without any of the tags.
I'm assuming it has to be something with the encoding and was wondering if someone can help


12 years ago
Hello,

I am trying to use HTMLUnit with GWT 2.1. This release of GWT has introduced the Places concept but I don't see that HTMLUnit has got support for that. Am I correct?
Any other tool I can use to create HTML snapshots for sites developed with GWT 2.1 and Places?
12 years ago
GWT
That's what I'm doing now however I break the term into words using String.split, is there a way for regexp to do this for me and include it in the same expression?
13 years ago
Hello,

I would like to create a regular expression that will match the following use case:
Suppose I have got a paragraph and a String as a search term. What I would like is to apply a regexp on the paragraph to let me know if the paragraph contains the search term itself or any of its words.
So, suppose the search term is "hello world" I would like to check if the paragraph contains the String "hello world" or any of the words "hello" or "wold".
The way I do it now is split the term by space and then search for each word separately however I am guessing that this can be done in much more elegant way using regexp and in one go.
Any ideas...?

13 years ago
DOTALL flag did the trick, thanks!
I thought that since I am not using the dot in my regexp then it will have no effect but I guess it does
13 years ago
Uhmmmm so there is no way to around this other than going through each stringbin the splitted array...?
13 years ago
Hello,

I have a long String coming from a different system that I am escaping using regexp using:



i.e. reserve only alphanumeric and white spaces.
The problem is that I still get the \n in the splitted array and I would like to remove it.
I can do a replaceAll("\\n", "") on each String in the array however would really prefer to do it in the original pattern before the split.

Any ideas...?

13 years ago
Hello,

I need to change an existing text in a PDF document.
I have started experimenting with Apache PDFBox and I am able to read the content of the PDF as text into a String using PDFTextStripper however I can't find the relevant API to write the amended String back into the file.
I am able to create new PDF with the new String however the new PDF is missing the styling and fonts that existed in the original PDF since PDFTextStripper only extracts the text (as the name suggests...)
I have found in the example folder a class called ReplaceString that is supposed to be doing exactly what I'm looking for but when I run it on a PDF it creates a very messy PDF and doesn't even do what it supposed to do.
I have decompiled that class and even there I don't see how the new PDF retains the styling and fonts that existed in the original PDF.
I know that there are other open source libraries out there (such as iText) however I don't think it has the same licensing as Apache has and therefore my company prefers not to use it.
This is as far as I have gone so far, would be great if someone can advise from his own experience how to achieve my goal using PDFBox.
The reason why I am transforming it to DOM is because the web service expects object type Node which is the root node of the xml and since I am creating the xml as a long String I need to transform it afterwards. I am aware that there is an API that allows you to create XMLs "properly" however in this case it is much simpler creating it as a String.
The xml does have nodes with no namespaces but I must follow the xml the other side expects and I am except that the defaul namespaces seems to be droppping on transformation...
13 years ago

Thank you for bringing this to my attention Paul.
You are correct, the default factory has namespaceaware set to false, I thought it is true by default.
I have added the setNamespaceAware(true) but it still seems to drop default namespaces, so for example:

This one goes through: xmlns:xsi="http://www.w3.org/2001/04/xmlenc#"
But this one doesn't: xmlns="http://www.w3.org/2001/04/xmlenc#"




13 years ago
Hello,

I am sending the root node of an xml over to a web service in this way:
1. I create the xml as a long Java String.
2. I convert the xml to a Document object and get the root node using this code:



The problem is that the other party who receives the root node complains that the default namespaces (xmlns attributes) are being dropped from the xml that he's receiving although I do include it in the xml String.
Any idea what could cause that?

13 years ago
I think I have made some progress with the BouncyCastle API.
I am now able to generate an X509 certificate from an RSAPublicKey object.
The question now is - Given a modulus and an exponent, how do I turn them into an RSAPublicKey object in Java?
Any ideas.........?
14 years ago
I agree with you but this is how they work so I'll just have to adopt myself to them if we want to work with them.
With other vendors we simply exchanged standard X509 certificates and I used them in my Java code in order to encrypt the sensitive information but here they work with the RSA Key itself.
I have actually digged a bit around openssl website but couldn't find what I'm looking for, any chance you (or someone) could show me an example of how to do it?

Many thanks.
14 years ago