This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Hide a URL: Example (Download THIS File)  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm currently developing a chat application and it offers file exchange. To make things easier for me I developed a simple FTP connection using Java’s URL Connection:
URLConnection urlc = url.openConnection();
InputStream is = urlc.getInputStream(); // To download
OutputStream os = urlc.getOutputStream(); // To upload

Now I want to hide the link or URL from the participants of the conversation; when a file is uploaded the link will be posted on the chat pane, and when clicked a download window will open (Similar to MSN messenger). I want to hide the link, any ideas on how to do it??
 
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
link.hide()

Kidding, but tagged because I need to find out the exact same thing for my customer as well.
 
author
Bartender
Posts: 3276
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hend Hamad wrote:Hello,

I'm currently developing a chat application and it offers file exchange. To make things easier for me I developed a simple FTP connection using Java’s URL Connection:
URLConnection urlc = url.openConnection();
InputStream is = urlc.getInputStream(); // To download
OutputStream os = urlc.getOutputStream(); // To upload

Now I want to hide the link or URL from the participants of the conversation; when a file is uploaded the link will be posted on the chat pane, and when clicked a download window will open (Similar to MSN messenger). I want to hide the link, any ideas on how to do it??



Have you thought about using Apache's FTP library or JSCH's SFTP library?

Also I assume by hiding the link you don't want to show:

http ://someserver:8080/file1.txt
 
Sheriff
Posts: 23640
48
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before we can tell you how to hide the link, we need to know how you are displaying the link in the first place. Is this a Swing application? A web application? Something else?
 
Hend Hamad
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Have you thought about using Apache's FTP library or JSCH's SFTP library?



Not Really .. I'll have to google them

Before we can tell you how to hide the link, we need to know how you are displaying the link in the first place. Is this a Swing application? A web application? Something else?



The link is sent in this format: ftp ://address:port/filename (optionally the path), and it is displayed in a swing application (Text Area) as a String so far.

I've been playing around with HTTP (http instead of ftp), I was able to download files from the webserver (Apache Tomcat). Hoewever; the upload seems to be much trickier and I couldn't find a way to do it!!

So I guess that I will continue using ftp ..
 
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using a TextArea or a JTextArea? I hope a JTextArea...

Consider using a Highlighter to act as a 'link' like you would get in HTML. The highlight will be used to mark specific text in the JTextArea. When you get a URL to the FTP download, parse out the file name, add that to the JTextArea. Create a Highlighter to the position of the word in the text that has a custom HighlightPainter to paint the 'link' text anyway you want. Then take the returned Object (usually a JLabel I think) and add a MouseListener that will begin the download when clicked.
JTextComponent#getHighlighter()
Highlighter
HighlightPainter
 
Hend Hamad
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Are you using a TextArea or a JTextArea? I hope a JTextArea...



I'm using JTextArea .. the 'J' was left out accidently

Consider using a Highlighter to act as a 'link' like you would get in HTML.



I will try your way .. I think it might just work .. Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!