Win a copy of Spring Boot in Practice this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Hide a URL: Example (Download THIS File)

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 27291
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic