File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes IDEs, Version Control and other tools and the fly likes Copy/paste issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Copy/paste issues" Watch "Copy/paste issues" New topic

Copy/paste issues

Charles Angemeyer

Joined: Dec 18, 2012
Posts: 22
In learning java I'll sometimes (not often) copy code from a web page and paste it into Eclipse so I can test it out.
For example I wanted to copy the code I found here:

In order to test out inner classes and improve my understanding of that feature.
When I copy the code and go to paste it, instead of breaking it apart, line by line, it gives me one very long line.
Is there a way to keep this from happening?
Many thanks.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

It works for me copying from Safari into TextEdit on a Mac. What are you copying from/into?

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Steve Luke

Joined: Jan 28, 2003
Posts: 4181

It is probably a side effect of either your browser on the way you are copying (example selecting bits of HTML that confuses the IDE). You can try CTRL+SHIFT+F in Eclipse to let it format the code for you. Should prevent the need to worry about the copy/paste problem.

Charles Angemeyer

Joined: Dec 18, 2012
Posts: 22
Ctrl-Shift-F worked great. Thank you very much.
(I'm using a Windows machine).
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46325
It should work the same on a *nix machine or a Mac.
I think this discussion would fit better in our IDEs forum: moving.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Copy/paste issues
It's not a secret anymore!