Jump to content

Java Question


bisketraja

Recommended Posts

How to access a file in a Network drive(Z:\\) using java?

From windows, I can just use  the path \\Z\\folder\\file.pdf but after deploying to the Tomcat server(Linux), it does not work. Any tools I can use to access the Network drive from linux using java?

Link to comment
Share on other sites

30 minutes ago, dewarist said:

linux lo drive letters undav kada. aa network drive em mount point lo mount chesado choosukoni access cheyali

for ex : /mnt/fileshare/....

yeah bhayya..kani mad vadu a drive ni mount cheyyale. Nenu JCIFS ani oka library undi danni use chesi try chesthunna UNC paths kosam. Currently stuck at this point

NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(user:pwd);

 

Autherntication failure ani vasthundi. NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domain", user, pwd); use cheddam antey domain ami ivvalo teleetla.
               

Link to comment
Share on other sites

This worked for me.. it shd work for u....

Just example:

create a folder called C:\data\june\2010... in your java code just write /data/june/2010 and access it 

 

 

 

Link to comment
Share on other sites

9 minutes ago, bisketraja said:

yeah bhayya..kani mad vadu a drive ni mount cheyyale. Nenu JCIFS ani oka library undi danni use chesi try chesthunna UNC paths kosam. Currently stuck at this point

NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(user:pwd);

 

Autherntication failure ani vasthundi. NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("domain", user, pwd); use cheddam antey domain ami ivvalo teleetla.
               

domain ni blank ivvadaniki try cheyi... or normal ga ni Windows machine lo login ayetappudu edithe domain use chestharo danitho try cheyi... 

Link to comment
Share on other sites

1 hour ago, compose said:

also jcifs use cheyali ante smb networking protocol enable ayi undali

 

2 hours ago, compose said:

domain ni blank ivvadaniki try cheyi... or normal ga ni Windows machine lo login ayetappudu edithe domain use chestharo danitho try cheyi... 

Thanks bhayya, Domain blank istey work ayyindi. 

path = "smb://networkName/folderName/fileName.txt";

 SmbFile sFile = new SmbFile(path, auth);
               SmbFileOutputStream sfos = new SmbFileOutputStream(sFile);
               sfos.write(fileContent.getBytes());

 

create cheyyadaniki paina code use chesthunna. fileName.txt okay kani fileName.pdf ani istey pdf create avthundi gani opening ravatla. File already in use ani vasthundi. Any ideas??

Basic ga na daggara file content antha html lo undi. Adi pdf loki convert chesi danni shared drive lo pettali.

Link to comment
Share on other sites

3 hours ago, bisketraja said:

 

Thanks bhayya, Domain blank istey work ayyindi. 

path = "smb://networkName/folderName/fileName.txt";

 SmbFile sFile = new SmbFile(path, auth);
               SmbFileOutputStream sfos = new SmbFileOutputStream(sFile);
               sfos.write(fileContent.getBytes());

 

create cheyyadaniki paina code use chesthunna. fileName.txt okay kani fileName.pdf ani istey pdf create avthundi gani opening ravatla. File already in use ani vasthundi. Any ideas??

Basic ga na daggara file content antha html lo undi. Adi pdf loki convert chesi danni shared drive lo pettali.

try like this

path = "smb://networkName/folderName/fileName.txt";
SmbFile sFile = new SmbFile(path, auth);

SmbFileOutputStream sfos = new SmbFileOutputStream(sFile);
byte[] buff=new byte[1024];
int len;

while((len=sfis.read(buff))>=0) { //here sfis is referring to the FileInputStream object
        sfos.write(buff,0,len);
}

  • Upvote 1
Link to comment
Share on other sites

On April 11, 2016 at 7:15 PM, compose said:

try like this

path = "smb://networkName/folderName/fileName.txt";
SmbFile sFile = new SmbFile(path, auth);

SmbFileOutputStream sfos = new SmbFileOutputStream(sFile);
byte[] buff=new byte[1024];
int len;

while((len=sfis.read(buff))>=0) { //here sfis is referring to the FileInputStream object
        sfos.write(buff,0,len);
}

evvar thalle nuv... adigina prathidaniki answer isthav... nak .net la doubts osthe bhi septhava finky fafa @3$% 

Link to comment
Share on other sites

On 4/11/2016 at 4:15 PM, compose said:

try like this

path = "smb://networkName/folderName/fileName.txt";
SmbFile sFile = new SmbFile(path, auth);

SmbFileOutputStream sfos = new SmbFileOutputStream(sFile);
byte[] buff=new byte[1024];
int len;

while((len=sfis.read(buff))>=0) { //here sfis is referring to the FileInputStream object
        sfos.write(buff,0,len);
}

good fost @compose @pinky1234

Link to comment
Share on other sites

On 4/11/2016 at 9:48 PM, bisketraja said:

How to access a file in a Network drive(Z:\\) using java?

From windows, I can just use  the path \\Z\\folder\\file.pdf but after deploying to the Tomcat server(Linux), it does not work. Any tools I can use to access the Network drive from linux using java?

property file pettukuni andhulo modify chesukomanu location ni 

appudu code change lekunda just property file lo property change chesukunte chalu 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...