< prev index next >

jdk/src/jdk.jline/share/classes/jdk/internal/jline/console/history/FileHistory.java

Print this page


   1 /*
   2  * Copyright (c) 2002-2012, the original author or authors.
   3  *
   4  * This software is distributable under the BSD license. See the terms of the
   5  * BSD license in the documentation provided with this software.
   6  *
   7  * http://www.opensource.org/licenses/bsd-license.php
   8  */
   9 package jline.console.history;
  10 
  11 import java.io.BufferedOutputStream;
  12 import java.io.BufferedReader;
  13 import java.io.File;
  14 import java.io.FileOutputStream;
  15 import java.io.FileReader;
  16 import java.io.Flushable;
  17 import java.io.IOException;
  18 import java.io.InputStream;
  19 import java.io.InputStreamReader;
  20 import java.io.PrintStream;
  21 import java.io.Reader;
  22 
  23 import jline.internal.Log;
  24 
  25 import static jline.internal.Preconditions.checkNotNull;
  26 
  27 /**
  28  * {@link History} using a file for persistent backing.
  29  * <p/>
  30  * Implementers should install shutdown hook to call {@link FileHistory#flush}
  31  * to save history to disk.
  32  *
  33  * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
  34  * @since 2.0
  35  */
  36 public class FileHistory
  37     extends MemoryHistory
  38     implements PersistentHistory, Flushable
  39 {
  40     private final File file;
  41 
  42     public FileHistory(final File file) throws IOException {
  43         this.file = checkNotNull(file);
  44         load(file);
  45     }


   1 /*
   2  * Copyright (c) 2002-2012, the original author or authors.
   3  *
   4  * This software is distributable under the BSD license. See the terms of the
   5  * BSD license in the documentation provided with this software.
   6  *
   7  * http://www.opensource.org/licenses/bsd-license.php
   8  */
   9 package jdk.internal.jline.console.history;
  10 
  11 import java.io.BufferedOutputStream;
  12 import java.io.BufferedReader;
  13 import java.io.File;
  14 import java.io.FileOutputStream;
  15 import java.io.FileReader;
  16 import java.io.Flushable;
  17 import java.io.IOException;
  18 import java.io.InputStream;
  19 import java.io.InputStreamReader;
  20 import java.io.PrintStream;
  21 import java.io.Reader;
  22 
  23 import jdk.internal.jline.internal.Log;
  24 import static jdk.internal.jline.internal.Preconditions.checkNotNull;

  25 
  26 /**
  27  * {@link History} using a file for persistent backing.
  28  * <p/>
  29  * Implementers should install shutdown hook to call {@link FileHistory#flush}
  30  * to save history to disk.
  31  *
  32  * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
  33  * @since 2.0
  34  */
  35 public class FileHistory
  36     extends MemoryHistory
  37     implements PersistentHistory, Flushable
  38 {
  39     private final File file;
  40 
  41     public FileHistory(final File file) throws IOException {
  42         this.file = checkNotNull(file);
  43         load(file);
  44     }


< prev index next >