Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void FileRequest() throws FileNotFoundException
- {
- try
- {
- ///
- output2 = new DataOutputStream(socket.getOutputStream());
- input = new DataInputStream(socket.getInputStream());
- System.out.println("Which file do you want?");
- Scanner scanner = new Scanner(System.in);
- String thisFileName = scanner.nextLine();
- System.out.println("99877");
- if(thisFileName!=null && !thisFileName.isEmpty())
- {
- System.out.println("666332");
- System.out.println("69683721");
- output2.writeUTF(thisFileName + "`" + "\n");
- System.out.println("1234123456666");
- output2.flush();
- System.out.println("flushed");
- long file_size= input.readLong();
- System.out.println("The file size is: " + file_size);
- if ( file_size == 0 )
- {
- System.out.println("File size is 0");
- }
- FileOutputStream file_out= new FileOutputStream( thisFileName );
- System.out.println("4445555");
- int number_read;
- byte[] buffer= new byte[1500];
- System.out.println("23234");
- while( (number_read= input.read( buffer)) != -1 )
- {
- file_out.write( buffer, 0, number_read );
- System.out.println("66333");
- }
- System.out.println("45531");
- System.out.println("File " + thisFileName + " downloaded (" + number_read + " bytes read)");
- System.out.println("123411");
- StandardInput();
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement