KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > nio > channels > FileChannel.MapMode

java.nio.channels
Class FileChannel.MapMode

java.lang.Object
  extended by java.nio.channels.FileChannel.MapMode
Enclosing class:
FileChannel
See Also:
Source Code, FileChannel.map(java.nio.channels.FileChannel.MapMode, long long)

public static final FileChannel.MapMode PRIVATE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1398]Map a file to memory
By kishorek_pamidi! { at } yahoo { dot } co { dot } in on 2005/06/06 03:32:12  Rate
import java.io.*; 
 import java.lang.*; 
 import java.nio.*; 
 import java.nio.Channel.*; 
  
  
 public class ExplicitChannel 
  {  
 public static void main ( String args [  ]  )  
  {  
 FileInputStream fin; 
 FileChannel fcn; 
 logn fsize; 
 MappedByteBuffer mbuf; 
 try 
  {  
 fin =new FileInputStream ( "test.txt" ) ; 
 fcn = fin.getChannel (  ) ; 
 fsize=fcn.size (  ) ; 
 mbuf=fcn.map ( fcn.MapMode.READ_ONLY,0,fsize ) ; 
 for ( int i=0;i < fsize;i++ )  
 System.out.print (  ( char ) mbuf.get (  )  ) ; 
 fcn.close (  ) ; 
 fin.close (  ) ; 
  }  
 catch ( IOException e )  
  {  
 System.out.println ( exec ) ; 
 System.exit ( 1 ) ; 
  }  
  }  
  } 


public static final FileChannel.MapMode READ_ONLY
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final FileChannel.MapMode READ_WRITE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String toString()
See Also:
Object
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags