Win a copy of Microservices in Action this week in the Web Services forum!
  • 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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
Posts: 3281
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: 23889
50
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: 4179
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!