Dustin Ward

+ Follow
since Jun 05, 2016
Dustin likes ...
Eclipse IDE Chrome Java
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dustin Ward

As someone that will soon pitch an enterprise level client on switching from 1.7 to (at least) 1.8, what are the biggest benefits of Lambdas and Streams (or any others if you care to discuss them)?

Also, in your opinion(s), what is the learning curve for really understanding what and how to use these new features?
2 years ago

Henry Wong wrote:
This week, we're delighted to have Raoul-Gabriel Urma, Mario Fusco & Alan Mycroft helping to answer questions about the new book Modern Java in Action: Lambdas, streams, functional and reactive programming.

The promotion starts Tuesday, December 4th, 2018 and will end on Friday, December 7th, 2018

We'll be selecting four random posters in this forum to win a free copy of the book provided by the publisher, Manning Publications.

Image from https://images-na.ssl-images-amazon.com

Please see the Book Promotion page to ensure your best chances at winning!

And ... the publisher, Manning Publications, is also running a special promotion. Please see these links for more information...


Posts in this welcome thread are not eligible for the drawing, and should be reserved for welcoming the author. Questions posted in this topic are subject to removal.

Welcome!! As someone about to convert from 1.7 to 1.8, this book may be perfect to understand the new features and their benefits.
2 years ago

Danny Markman wrote:Thank you so much for your post very useful.  Do I really need certificate or just some portfolio enough to get a proper job? I just don't like to spend my money.

I cannot speak to being certified as I am not, but I have a proper job. I have been a Java developer (well, more full stack if I am being honest) about a year ago with no certificate.

I am not advocating to NOT get certified, but its not necessary for the job. I also did not have a degree in CS (philosophy, actually, ha!). But I don't think my route to a job was the standard one and I would think a certificate would definitely help.
So let me explain the subject line. I am (shudder) using Java EXT to create some panels and such on the front end. When I click on some button that does calculations, I would like to have either a popup or a new window open (this one is not necessarily relegated to EXT) and show my process on the back end (java7) in a 'live' fashion. It really doesn't need to be truly live. It can show every two seconds or some such. I would like the output to be things I log in the controller/ service that I call so I can see the process on the front end.

The way I am currently considering doing it is to create a "job" (really a task) that reads a file that I write to every n seconds and then just replaces the whole output in the new page.

My question is: is there an easier way to do this, like by changing standard out to an output stream? Can I even accomplish this without a job running every n seconds?

Please let me know if there is any additional information needed. THANKS!
3 years ago

Tim Holloway wrote:I think I can clear up that last.

You're retrieving a collection of "file descriptor" objects. As you call them, metadata. The traditional equivalent for that would be directory entries.

In many filesystems, a directory entry isn't an integral part of a file, it's a distinct object that describes and locates the file within file allocation space. Again, metadata.

In the case of Swift objects, the "locator" part of the metadata is a URL, since Swift storage is http-protocol addressable. That's what you have to get a handle on in order to access the file data itself.

Thank you, that makes sense.

In the end, making the "filetree" out of their system was pretty easy:

the `mkdirs()` call is pretty great, it does the heavy lifting
4 years ago

Tim Holloway wrote:OK. You're definitely retrieving Swift objects and not traditional files. Which means that actually this question is a candidate for the Cloud/Virtualization forum.

A superficial check of the docs seems to indicate that what you're doing should work. You could always poke around a bit just to make sure.

Two things that you might try are these:

1. Close the outputstream before you close the Inputstream. You might even want to flush it first. Just in case the copy process needs a bit of jogging.

2. Replace the openStream call with a call to getInput(). They're supposed to function identically, but just in case...

Also try manually reading the InputStream just to see what it returns.

openStream is definitely not returning null. Otherwise it would be causing NullPointerException's. But it could possibly be returning positioned at end-of-file or an empty stream.


So it looks like it was a small mistake on my part. Or me just not understanding exactly what the jcloud API did. When I called

It was only giving me a list of the objects and with the `get()` call, I was only getting, for lack of a better term, the metaData. I wasn't getting the whole object. Instead, I had to use:

So, I got the list of objects, made a temporary object just to get the name of the X object and used its name to get the ACTUAL object. I don't really understand why this is the way it is (why wouldn't the first call work?) but thankfully I figured it out with a lot of testing.

Thanks again to everyone in this thread who answered!
4 years ago

Tim Holloway wrote:
You mentioned a Rackspace API (jCloud), however, so I'm not really certain that what you are talking about is a true filesystem. It might be a cloud object store such as Amazon's S3 - or for Openstack, the Swift storage mechanism. In which case, you're not really talking about files as such, but objects addressed (and downloadable) via URL requests. In that case, neither rsync nor nio would work.

Turns out you are correct, but actually, I figured out a solution that presents another problem.... I used:

Ok, so the "filesystem" which turns out to be flat... not really a tree... remains in tact.

My problem now is that when I am trying to copy the content or data over, it isn't working. Here is my updates code:

Ok, so I know this is probably difficult to solve because it uses jCloud to access Rackspace, but when I error-check my inputStream (inputStream.available() or inputStream.read()) they both show an empty inputstream.... BUT, when I remove the .openStream from the end of  InputStream inputStream = object2.getPayload().openStream(); and use Payload pl = object2.getPayload(); it shows actual data size. So, somehow (i think) the method openStream() isn't working... or it is returning null for some reason.

any ideas.......?

And Ron, I think this is- unfortunately- the way I have to access these files...

4 years ago

Ron McLeod wrote:Rather than create your own network file copy mechanism, you might want to consider using something that already exists - such as a application or library based on SCP or SFTP or rsync.

What operating systems do the server and local platforms run?

I'm not sure what Rackspace runs on. My local computer runs Windows.

The problem is I am not sure Rackspace allows that type of connection. To download files from their servers, they give an API that uses jClouds. I have most of it configured correctly and I can even copy the files onto my computer with the above code but at this point, I copy them all as text files. So they come out as "root.txt" "test1.txt" and "whatever.html.txt" because I haven't configured the filename strings correctly.

Honestly, it'd be much less of a hassle if they let me do it a different way but at this point, if I an figure out how to say like:

If (theFile has no /, create a directory)
Elseif (theFile contains a ., separate into two pieces: whatever and .html)
Else (create a sub folder)

Lol perhaps I am making that too complicated
4 years ago

Ron McLeod wrote:Maybe I am misunderstanding what you are trying to do, but it sounds like you want to copy a set of files from a server platform to your local platform and maintain the structure of the files that are in the server's file system.  Is that correct?

Yes. The way I currently know to do so with the API I am using is that the above file I pretended to have gives the file structure which I need to maintain. So the top directory would be Root with a subfolder of test1 and a file called whatever.html (can't remember what I called it above).

Anyway, the API wants the file name and the extension, so I think I need to break up the filename (like "root/test1/whatever.html" into whatever and .HTML so the TempFile is made correctly.

At least, that is the way I think i need to do it. Of anyone has a better idea, I'd be all ears.

I can't just transfer the files directly, they are actually on a server far, far away on Rackspace and there are thousands of files. The API to do so uses jClouds to accomplish the task and is basically what I put in my original post.

I hope that makes sense! Thank you!  
4 years ago
Okay, so lets pretend I have a certain container and in each container was an "object" (really just a file of some sort). I open the container and pull out each object.

The first is a folder called "Root"
Second, a subfolder called "Root/test1"
Then a file called "Root/test1/ReleaseNotes.html"

I am trying to take those objects and copy them to my local computer. I don't actually know the names ahead of time because there are going to be several hundred files.

My plan is to open an InputSteam, create a temporary file and then creat a BufferedOutputStream  and copy it via ByteStreams

OK... so my question is... how best should I get the files to "follow" or make the filetree? When I copy them, is there a way to do that? I am currently looking at the String.split function, but that erases the delimiter, correct? Any help is appreciated!
4 years ago
Hi guys. I am trying to let someone change their password in my GUI and I would like a pop up to have them give me their old password and then another to allow them to enter a new password (twice to confirm)... I originally thought I could use TextInputDialog and then "hide" the input with asterisks or something along that nature, but I couldn't find anything. SO, I googled my brains out and found a few 'create a custom dialog' posts. Well, I googled all of that and none seemed to make a lot of sense. In fact, when I tried to copy paste their code into Eclipse to try and fiddle with their code, I couldn't even get Dialog to build correctly.

Does anyone have any ideas? What my GUI consists of so far, is a primaryStage with a bunch of different scenes that interchange with button clicks. I could switch the scene again- easy enough- and give three text fields, but I was hoping to solve this for my sanity and for consistency. Thanks!
4 years ago

Dustin Ward wrote:How and where would I overwrite the LocalDateTime .toString? Like, I've overwritten all of my CLASS' toString's but how do I just overwrite a random objects?

Because I would really like to print it off without the T and although I elected the military time, I'd like to write it out in standard 1-12 time without making people specify AM or PM when I get their input

Woohoo! Nevermind. I figured it out.

and then I just printed formattedDateTime instead of just dateTime!

Edit to add: Even cooler that I just found is that if you change the Formatter from HH:mm (which is military time) to hh:mm a, it will automatically convert it to the standard 1-12 time AND print off AM/PM! Awesome!

Roel De Nijs wrote:

Dustin Ward wrote:I do get a 'T' in the middle of my output though, which is weird...

No, that's not weird at all. It is just the textual (string) representation of a LocalDateTime instance as explained in the toString() method.

Dustin Ward wrote:Ohhhh. Well, it actually works when I insert it into mysql table using DATETIME so I am cool with it

Of course it will work when inserting it into a MySQL database table, because the textual representation is not used in the MySQL driver to insert/updata a DATETIME column. It only offers some information about the object in (hopefully) a human-readible format.

How and where would I overwrite the LocalDateTime .toString? Like, I've overwritten all of my CLASS' toString's but how do I just overwrite a random objects?

Because I would really like to print it off without the T and although I elected the military time, I'd like to write it out in standard 1-12 time without making people specify AM or PM when I get their input
Also, in case anyone comes upon this, because of the format I was using (MM-dd-yyyy hh:mm a) it requires the a (which indicates AM/PM) because the lowercase h signifies hours in 1-12 where as the uppercase H signifies what Americans call military time (1-24) and does NOT need the a

Carey Brown wrote:Your statement
will use the default format which is an international standard which includes the 'T'.

Ohhhh. Well, it actually works when I insert it into mysql table using DATETIME so I am cool with it