Package java.nio.channels

Examples of java.nio.channels.FileChannel.map()


      long size) throws IOException {
    FileChannel channel = raf.getChannel();

    boolean threw = true;
    try {
      MappedByteBuffer mbb = channel.map(mode, 0, size);
      threw = false;
      return mbb;
    } finally {
      Closeables.close(channel, threw);
    }
View Full Code Here


                            length = 4096;
                        } else {
                            length = remaining;
                        }
                       
                        MappedByteBuffer buffer = fc.map(MapMode.READ_ONLY, offset, length);
                        ByteBuffer[] bufs = new ByteBuffer[] { buffer };
                 
                        outChannel.write(bufs, this);
                           
                        offset += length;
View Full Code Here

                            length = 4096;
                        } else {
                            length = remaining;
                        }
                       
                        MappedByteBuffer buffer = fc.map(MapMode.READ_ONLY, offset, length);
                        ByteBuffer[] bufs = new ByteBuffer[] { buffer };
                 
                        outChannel.write(bufs, this);
                           
                        offset += length;
View Full Code Here

                            length = 4096;
                        } else {
                            length = remaining;
                        }
                       
                        MappedByteBuffer buffer = fc.map(MapMode.READ_ONLY, offset, length);
                        ByteBuffer[] bufs = new ByteBuffer[] { buffer };
                 
                        outChannel.write(bufs, this);
                           
                        offset += length;
View Full Code Here

                            length = 4096;
                        } else {
                            length = remaining;
                        }
                       
                        MappedByteBuffer buffer = fc.map(MapMode.READ_ONLY, offset, length);
                        ByteBuffer[] bufs = new ByteBuffer[] { buffer };
                 
                        outChannel.write(bufs, this);
                           
                        offset += length;
View Full Code Here

 
  private String readFile(String path) throws IOException {
    FileInputStream stream = new FileInputStream(new File(path));
    try {
      FileChannel fc = stream.getChannel();
      MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc
          .size());
      /* Instead of using default, pass in a decoder. */
      return Charset.forName("ISO-8859-1").decode(bb).toString();
    } finally {
      stream.close();
View Full Code Here

 
  private String readFile(String path) throws IOException {
    FileInputStream stream = new FileInputStream(new File(path));
    try {
      FileChannel fc = stream.getChannel();
      MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc
          .size());
      /* Instead of using default, pass in a decoder. */
      return Charset.forName("ISO-8859-1").decode(bb).toString();
    } finally {
      stream.close();
View Full Code Here

            }
            in = new FileInputStream(source).getChannel();
            out = new FileOutputStream(dest).getChannel();

            long size = in.size();
            MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size);

            out.write(buf);

        } finally {
            if (in != null) {
View Full Code Here

        boolean capped = false;
        int lineCount = 0;
        try {
            RandomAccessFile raf = new RandomAccessFile(file, "r");
            FileChannel fc = raf.getChannel();
            MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
            CharBuffer cb = Charset.forName(System.getProperty("file.encoding")).decode(bb);
            Matcher target = null;
            Matcher any = null;
            Matcher lines = FULL_LINE_PATTERN.matcher(cb);
            Matcher text = textSearch == null ? null : textSearch.matcher("");
View Full Code Here

                       || (start>0 && start<=logFileTime && end>0 && end>=logFileTime)) {

                        // It's in the range, so process the file
                        RandomAccessFile raf = new RandomAccessFile(logFiles[i], "r");
                        FileChannel fc = raf.getChannel();
                        MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
                        CharBuffer cb = Charset.forName("US-ASCII").decode(bb); //todo: does Jetty use a different charset on a foreign PC?
                        Matcher lines = FULL_LINE_PATTERN.matcher(cb);
                        Matcher target = ACCESS_LOG_PATTERN.matcher("");
                        SimpleDateFormat format = (start == 0 && end == 0) ? null : new SimpleDateFormat(ACCESS_LOG_DATE_FORMAT);
                        int max = maxResults == null ? MAX_SEARCH_RESULTS : Math.min(maxResults.intValue(), MAX_SEARCH_RESULTS);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.