Sunday, May 26, 2013

File Writing In Java

/*Program For File Writing In Java*/

import java.io.*;


class simple
  {
      public static void main(String args[])throws Exception
        {
                File f=new File("F:\\YOGESH (COLLEGE PROJECTS)\\sybsc");
            String fnames[]=f.list();
             

    System.out.println("NAME"+"  "+"LENGTH"+"  "+"STATUS"+"  "+"TYPE");

            for(int i=0;i<fnames.length;i++)
{
  File f1=new File("F:\\YOGESH (COLLEGE PROJECTS)\\sybsc",fnames[i]);
       
               System.out.print(" "+f1.getName());
   System.out.print(" "+f1.length());
if(f1.canRead()==true)
{
  System.out.print(" "+"R");
}
if(f1.canWrite()==true)
 {
   System.out.print(" "+"w");
 }
if(f1.isFile()==true)
{
  System.out.print(" "+"FILE");
}
if(f1.isDirectory()==true)
{
 System.out.print(" "+"DIR");
}
                        System.out.println("");
       }
      }
 }

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...