Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Create file in java and write it to a different server on a different network  RSS feed

 
Craig Dumolien
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a java application where I need to create a file, without an extension, in code and write it to a different server on another network. Our company currently is on 2 networks. Both servers are Windows. The server I need to write to will need a user name and password. What is the best way to do this? Examples would be helpful.
 
Matt Cartwright
Ranch Hand
Posts: 152
Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you get to that other server?

Socket connection?

Protocol?

Or do you have to implement the receiving end as well?
 
Craig Dumolien
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Protocol
 
Matt Cartwright
Ranch Hand
Posts: 152
Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What protocol?
 
Craig Dumolien
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was thinking I would just be able to use the file protocol. I'm not sure. We haven't done anything like this before. From what I've seen, I think I should be able to use a URL object with the file protocol and set my username and password as an authorization on the RequestProperty.
 
Paul Clapham
Sheriff
Posts: 22485
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You say that a user name and password are going to be required, so I take that to mean that you won't have a drive mapped to that server on the machine where you're going to be creating this file.

So in that case a file:// URL isn't going to work because there isn't any way to find the target file on that source machine.

I have been using jCIFS for zapping files around Windows networks and it works just fine, even on computers which aren't running Windows.
 
Matt Cartwright
Ranch Hand
Posts: 152
Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:
I have been using jCIFS for zapping files around Windows networks and it works just fine, even on computers which aren't running Windows.


In that case the protocol would be SMB.
 
Craig Dumolien
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the point in the right direction. That worked great.
 
Paul Clapham
Sheriff
Posts: 22485
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matt Cartwright wrote:
Paul Clapham wrote:
I have been using jCIFS for zapping files around Windows networks and it works just fine, even on computers which aren't running Windows.


In that case the protocol would be SMB.


Correct. But in this case you don't have to go around begging for somebody to set up an "SMB server", as you might have to if you chose the FTP protocol. SMB is always-on in a Windows network.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!