Read files at window server from Sun Server by a java program

Dear All,

Please advise,

How can i read files/directory by a java program from sun server to window server please?

I can connect to the Window Server by the Socket. But, still not sure what do i miss out as the file.isDirectory still return "False" value.

Here is the code:

try {

Socket MyClient = new Socket("122.12.21.12", 80);

SocketPermission sp = new SocketPermission("122.12.21.12:80","accept");

DataInputStream dis;

DataOutputStream ops;

PrintStream os;

//workable String sSeperator = "\\";

String sSeperator = "\\";

String sSeperator1 = "\\";

String sSeperator2 = "\\\\";

//System.out.println(System.getSecurityManager());

System.out.println("MyClient.getInetAddress().getHostAddress() >>> " + MyClient.getInetAddress().getHostAddress());

System.out.println("getInetAddress() := " + MyClient.getInetAddress());

System.out.println("MyClient.isConnected() ? >>> " + MyClient.isConnected());

Runtime runtime = Runtime.getRuntime();

try

{

FilePermission fp = new FilePermission(sSeperator2.replaceAll("//", "\\\\")+MyClient.getInetAddress().getHostAddress()+sSeperator1+"DoNotTouchThise cVisionXMLimportantfiles", "read");

System.out.println("fp > " + fp.toString());

File file = new File(sSeperator2.replaceAll("//", "\\\\")+MyClient.getInetAddress().getHostAddress()+sSeperator+"DoNotTouchThisec VisionXMLimportantfiles"+sSeperator);

System.out.println("System.getProperty(file.separator) := " + System.getProperty("file.separator"));

dis = new DataInputStream(MyClient.getInputStream());

ops = new DataOutputStream(MyClient.getOutputStream());

os = new PrintStream(MyClient.getOutputStream());

System.out.println("file.canRead() :=" + file.canRead());

System.out.println("file.canWrite() :=" + file.canWrite());

System.out.println("file.isDirectory() :=" + file.isDirectory());

System.out.println("file.getPath()" + file.getPath());

MyClient.close();

System.out.println("MyClient.isClosed() ? >>> " + MyClient.isClosed());

response.sendRedirect("../index.jsp");

}catch (IOException e)

{

System.out.println("MyClient.isConnected() ? >>> " + MyClient.isConnected());

if (MyClient.isConnected() == true)

{

MyClient.close();

System.out.println("MyClient.isClosed() ? >>> " + MyClient.isClosed());

}

System.out.println("IOE error := " + e.getMessage());

System.out.println("IOE error := " + e.getCause());

System.out.println("IOE error := " + e.getClass());

}

}

catch (SocketException se)

{

System.out.println("Caught socket exception");

}catch (UnknownHostException uhe)

{

System.out.println("Caught unknown host exception");

}catch (IOException ex)

{

System.out.println("IOE error big:= " + ex.getMessage());

System.out.println("IOE error := " + ex.getCause());

System.out.println("IOE error := " + ex.getClass());

}

%>

<BODY>

</BODY>

</HTML>

Thanks.

Tommy

[3241 byte] By [lwy2020] at [2007-11-26 8:39:22]
# 1

> How can i read files/directory by a java program from sun server to window server please?

If by "sun server" you mean Solaris server, then in order to read its files/directories, you need to get them exported via NFS, for example. After that, you need to mount this exported directory on Windows machine. I belive, there are tools to do that, but I'm not familiar with them.

And, of course, this is more generic than Java. Export/mount are at OS level.

MaximKartashev at 2007-7-6 22:14:31 > top of Java-index,Development Tools,Solaris and Linux Development Tools...