Content about Java ERP Solution for Reviews Best ERP Software for sale and Free Software with Java OpenSource for Free Download

Javascript array loop example code for loop array in javascript

You can loop data in javascript array by using index and limit with array.length for example code in below

 <script>  
    // Create array of String  
    arrayObj=["CAT","DOG","MAN","CAR"];  
    for (var i=0;i<arrayObj.length;i++)  
      document.write(arrayObj[i] + "<br>");  
    }  
 </script>  

The out put is

CAT

DOG

MAN

CAR

File in Java how to Read and Write File in Java

You can use class in package java.io.* to manage file with java
for example below

Example code for read file line by line with Java

  FileInputStream fs = new FileInputStream("filename.txt"); 
  DataInputStream ds = new DataInputStream(fs);
  BufferedReader br = new BufferedReader(new InputStreamReader(ds));
  String tmp; 
  while ((tmp = br.readLine()) != null)   {
      System.out.println (tmp);
  } 
  ds.close();


Example code for Write file with java
  FileWriter fw = new FileWriter("file_name.txt");
  BufferedWriter out = new BufferedWriter(fw);
  out.write("Test Wrrite1");
  out.write("Test Wrrite2");
  out.write("Test Wrrite3");  
  out.close();