Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

exits adn copy file in java

//java code
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyFileStream {

    public static void main(String[] args) throws IOException {

        var source = new File("src/resources/bugs.txt");
        var dest = new File("src/resources/bugs2.txt");

        try (var fis = new FileInputStream(source);
             var fos = new FileOutputStream(dest)) {

            byte[] buffer = new byte[1024];
            int length;

            while ((length = fis.read(buffer)) > 0) {

                fos.write(buffer, 0, length);
            }
        }
    }
}
//bugs.txt
Assasin bug, Avondale spider, Backswimmer,
Bamboo moth, Banana moth, Bed bug,
Black cocroach, Blue moon, Bumble Bee,
Carpenter Bee, Cattle tick, Cave Weta,
Cicada, Cinnibar, Click beetle, Clothes moth,
Codling moth, Centipede, Earwig, Eucalypt longhorn beetle,
Field Grasshopper, Garden slug, Garden soldier,
German cockroach, German wasp, Giant dragonfly,
Giraffe weevil, Grass grub, Grass looper,
Green planthopper, Green house spider, Gum emperor,
Gum leaf skeletoniser, Hornet, Mealybug,
Mites, Mole Cricket, Monarch butterfly,
Mosquito, Silverfish, Wasp,
Water boatman, Winged weta, Wolf spider,
Yellow Jacket, Yellow Admiral
Comment

PREVIOUS NEXT
Code Example
Typescript :: nullish coalescing angular example 
Typescript :: get list of property values from list of objects swift 
Typescript :: how to collect array of objects in one value key in laravel 
Typescript :: CUSTOM_ELEMENTS_SCHEMA error occur while unit testing with jasmine and karma 
Typescript :: collection that accepts duplicate keys 
Typescript :: w to check whether an image is a broken image or not in typescript angular 
Typescript :: common child hackerrank solution 
Typescript :: flutter create widget for each element of list 
Typescript :: how to pass node arguments in nextjs 
Typescript :: representation of graph usig sets and hash in python 
Typescript :: number square n times in typescript 
Typescript :: typescript enum includes value 
Typescript :: typescript hello world 
Typescript :: real time charts in flutter 
Typescript :: prolog check if element in different lists are same 
Typescript :: find number of digits that changed after addition of 1 
Typescript :: inline scripts encapsulated in <script tags 
Cpp :: git branch in my bash prompt 
Cpp :: c++ primality test 
Cpp :: unreal engine delay c++ 
Cpp :: vhdl integer to std_logic_vector 
Cpp :: c++ count bits 
Cpp :: sfml set font 
Cpp :: eosio multi index clear 
Cpp :: multiply image mat by value c++ 
Cpp :: map of vector of struct error 
Cpp :: C++ add value to exception message 
Cpp :: initialzing a 2d vector in cpp 
Cpp :: max three values c++ 
Cpp :: remove value from vector c++ 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =