{{theTime}}

Search This Blog

Total Pageviews

File to File Copy Using Java Streams

  1. package com.dev.concurrent;
  2. import java.io.FileInputStream;
  3. import java.io.FileOutputStream;
  4. import java.io.IOException;
  5. /**
  6.  * File to File Copy using Java Streams.
  7.  *
  8.  */
  9. public class StreamExample
  10. {      
  11.     public void byteStreamExample() {       
  12.         try(FileInputStream in = new FileInputStream("samplein.txt")) {
  13.             try (FileOutputStream out = new FileOutputStream("sampleout.txt")) {           
  14.                 int c;
  15.                 while ((c = in.read()) != -1) {
  16.                     out.write(c);
  17.                 }
  18.             }catch (IOException e) {
  19.                 e.printStackTrace();
  20.             }
  21.         } catch (IOException e) {
  22.             e.printStackTrace();
  23.         }
  24.     }
  25.      
  26.     public static void main(String[] args)
  27.     {   
  28.         StreamExample se = new StreamExample() ;
  29.         se.byteStreamExample() ;
  30.     }
  31. }

No comments:

FastAPI throws an error (Error loading ASGI app. Could not import module "main")

Make sure the main fastapi code is in the same directory where you are running the code.