sockets - Is java's File class' object serializable? -


I am working on a project, it requires sending the directory information from one client to another on the network. So tell me, can I get this information only by sending the file class object to another file? Please tell me the reasons for your yes or no.

Renewed Questions

I am posting that code for which I have tried ....

Customer code {- Soft Sock = New Socket ("10.16.10.82", 4000); / * Socket Sock: -

  Public class file client {public static zero main (string str []) = New socket ("127.0.0.1", 4000); * / // f = new file for localhost file ("MyFile.txt"); ObjectOutputStream OS = New ObjectOutputStream (sock.getOutputStream ()); os.writeObject ( F); os.flush (); os.close (); System.out Println ("object sent");} hold (ex before) {ex.printStackTrace ();}}}  

and the following is the server code: -

 < Code> class fileerver {public static void main (string str []) {try server server = Socket = new server (4000); while (true) {socket cs = sock.accept (); ObjectInputStream = new ObjectInputStream (cs.getInputStream ); In file F = (file) in.readObject (); Println (f.isDirectory ()); System.out.println (f.length () + "Read bytes"); }} Hold (Exception pre) {ex.printStackTrace (); }}}  

If I run the server on the local host but when I use two and two other machines for the client, then it works fine (read this bytes) goes). It looks right because the actual file is not available on the remote server. I am confused about the file class area, i.e.

  stable private file system fs = FileSystem.getFileSystem () // file See javadoc for  

What is the correct information after reading the file object?

Yes you can send information using the file class reference because This applies the serialjob interface

For more details, read Java's file .

Example of code

You can get it by following the following code:

  string source filefilename = "path.txt"; {File file = try new file (sourcePathFilename); FileOutputStream fos = New FileOutputStream (string target path); ObjectOutputStream OOS = New ObjectOutputstream (fos); Oos.writeObject (file); } Hold (exception e) {e.printStackTrace (); }  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -