Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Stephanie Smith

Greenhorn
+ Follow
since Jun 28, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 Stephanie Smith

I have a String that is delimited by commas

Value1, value2 , value3

However i want to be able to allow a value that has a comma. So it would have to be escaped.....perahps

value1, value2, value3, value4\,HasAComma


Is there a way to use String.split() to parse this such that the returned values
are

value1
value2
value3
value4,HasAComma

Thanks for any advice. wasn't sure if this could be accomplished via a regular expression or not.
11 years ago
I want to generate unique names.
The VMID object is unique within a jvm.
I create the VMID, and then pass the bytes into CRC32 and convert to hex string.

Should this generated hex string be unique within like 100,000 iterations of creating a name? how likely are duplicates?
I have tested it with over 700K iterations (of creating VMID, passing into CRC32 and converting to hex string) with no duplicates but wanted to know if duplicates were possible.

Thanks for any advice.
14 years ago
What is the best way to compare two binary files in java?
SHould I just read in the files using streams and compare each byte?

Or should I use checksums? Is one better than the other?
15 years ago
In the JMX example, it starts a Server application.
Basically it initiates the MBeanServer, creates the ConnectorServer
and then starts the connector and that is it as far as the code goes.

Why does the server application not exit but continue to run? Is that because the RMI connector server is listening for incoming connections?
Is another thread created to do this?

// Create an RMI connector server
//
System.out.println("\nCreate an RMI connector server");
JMXServiceURL url = new JMXServiceURL(
"service:jmx:rmi:///jndi/rmi://localhost:9999/server");
JMXConnectorServer cs =
JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);


// Start the RMI connector server
//
System.out.println("\nStart the RMI connector server");
cs.start();
System.out.println("\nRMI connector server successfully started");
System.out.println("\nWaiting for incoming connections...");
16 years ago
I am using a JMX RMI connector.

When I try to connect, I am getting a AccessControlException
access: access denied (java.net.SocketPermission 10.26.12.110:3399 connect,resolve)

I am using a SecurityManager and I have a policy file. I am only granting permissions to those needed.

The only way I can get this to work is to grant everyone this
SocketPermission:

grant {
permission java.net.SocketPermission "*:1024-65535", "connect,accept,resolve";

};

My QUestion is this:
If I try to grant this to a specific codebase or principal, i always get the exception. Is it required that this SocketPermission be granted to everyone?

As an fyi, here is the traceback to give you some context,

access: access denied (java.net.SocketPermission 10.26.12.110:3399 connect,resolve)
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1064)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:258)
at java.security.AccessController.checkPermission(AccessController.java:401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1026)
at sun.rmi.transport.tcp.TCPChannel.checkConnectPermission(TCPChannel.java:119)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:148)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:101)
at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
at javax.management.remote.rmi.RMIConnectionImpl_Stub.getConnectionId(Unknown Source)
at javax.management.remote.rmi.RMIConnector.getConnectionId(RMIConnector.java:332)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:294)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:247)
at StandAloneMBeanServer2.doesItExist(StandAloneMBeanServer2.java:99)
at StandAloneMBeanServer2.main(StandAloneMBeanServer2.java:40)


ccess: domain that failed ProtectionDomain (null <no certificates>
com.sun.jmx.remote.util.NoCallStackClassLoader@2ba11b
<no principals>
java.security.Permissions@1e328e0 (
(java.net.SocketPermission localhost:1024- listen,resolve)
(java.util.PropertyPermission java.version read)
(java.util.PropertyPermission java.vm.name read)
(java.util.PropertyPermission java.vm.vendor read)
(java.util.PropertyPermission os.name read)
(java.util.PropertyPermission java.vendor.url read)
(java.util.PropertyPermission java.vm.specification.vendor read)
(java.util.PropertyPermission java.specification.vendor read)
(java.util.PropertyPermission os.version read)
(java.util.PropertyPermission java.specification.name read)
(java.util.PropertyPermission java.class.version read)
(java.util.PropertyPermission file.separator read)
(java.util.PropertyPermission java.vm.version read)
(java.util.PropertyPermission os.arch read)
(java.util.PropertyPermission java.vm.specification.name read)
(java.util.PropertyPermission java.vm.specification.version read)
(java.util.PropertyPermission java.specification.version read)
(java.util.PropertyPermission java.vendor read)
(java.util.PropertyPermission path.separator read)
(java.util.PropertyPermission line.separator read)
(java.io.FilePermission C:/j2sdk1.4.2_05/Jre/lib/ext/x86/QProfJ.dll read)
(java.lang.RuntimePermission loadLibrary.QProfJ)
(java.lang.RuntimePermission stopThread)
)
16 years ago
I would like to have one xsl stylesheet that can be used
to create text, html or xml output. Is there a way to
conditionally set the <xsl utput method=""> method attribute
based on an input parameter?

Or will I just need to create three different xsl stylesheets and use the appropriate one, depending on what the desired output method is?
I create a URL with this constructor and it works fine:
URL u = new URL("ftp", "localhost", 21, "\\channels");
I then invoke u.toString() and it prints out
ftp://localhost:21\channels
So this makes it appear that using the "\" is valid and the URL is valid.
If I then try to create a second URL with this string:
URL u2 = new URL(u.toString());
it fails with
java.net.MalformedURLException: For input string: "21\channels"
at java.net.URL.<init>(URL.java:613)
at java.net.URL.<init>(URL.java:476)
at java.net.URL.<init>(URL.java:425)

So my question is, why does this second one fail and the first one succeed? thanks
If I use File.createTempFile(), does it
make sure that the file does not already
exist before it creates the file?
Or do I need to provide some uniqueness
with the suffix/prefix info I provide?
19 years ago
I have a text file object where the constructor
takes an input stream. The interface has a
getReader() call that returns the reader
for this text file object.
In my implementation, if I just return a reader
using this input stream like:
return new InputStreamReader(inputStream);
Then its a one time use implementation. The first
call returns the reader. Its read until end of stream. The calling application closes the reader
and so it can't call getReader() a second time.
Any ideas on how the implementation can make
this stream re-usable? So it can be used more
than one time?
19 years ago
I am trying to delete a file using the FTP protocol. I was looking at the URL class but there doesn't appear to be a way to do this....do I have to write an ftp client in order to perform this deletion using ftp?
thanks steph
The http protocol supports a delete command but I do not see this supported by the URL class.
Any suggestions on how I can delete a file using the HTTP protocol from within java?
thanks steph
User error. THis works as expected by just calling setAttributeNS() multiple times.
I would like to define multiple namespaces
in my root element (using DOM).
I tried this, but when I excecute this
code, only the first declaration exists
in the serialized xml document:
root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:a", "http://www.someHost.com/a");
root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:b", "http://www.someHost.com/b");
How can this be done? thanks
UTF-8 is the default, but in this
case I'm using a StringWriter as well.
So when I get the String representation its
in Unicode....so just wondering
if there was a conversion
there between utf-8 and unicode.
Thanks for your help! -steph
I have seen this documented as a way to convert
the XML document to a String:
StringWriter sw = new StringWriter();
XMLSerializer ser = new XMLSerializer(sw, new OutputFormat());
ser.serialize(document);
String s= sw.getBuffer().toString();

Does this actually convert the XML (in UTF-8)
to Unicode?