Ignore:
Timestamp:
2016-10-26T15:37:24+13:00 (7 years ago)
Author:
davidb
Message:

Getting closer to writing out JSON files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/hathitrust/solr-extracted-features/trunk/src/main/java/org/hathitrust/ClusterFileIO.java

    r30941 r30945  
    2121import org.apache.hadoop.fs.FileSystem;
    2222import org.apache.hadoop.fs.Path;
    23 import org.apache.spark.api.java.JavaSparkContext;
    2423
    2524public class ClusterFileIO {
     
    5857    */
    5958   
    60     public static FileSystem getFileSystemInstance(String input_dir)
     59    protected static FileSystem getFileSystemInstance(String input_dir)
    6160    {
    6261        if (__fs == null) {
     
    8281    }
    8382   
    84     protected static boolean exists(String file)
     83    public static boolean exists(String file)
    8584    {
    8685        FileSystem fs = getFileSystemInstance(file);
     
    10099        return exists;
    101100    }
    102     protected static BufferedInputStream getBufferedInputStream(String fileIn)
     101   
     102    public static String removeSuffix(String file,String suffix)
     103    {
     104        return file.substring(0,file.length() - suffix.length());
     105    }
     106   
     107    public static boolean createDirectoryAll(String dir)
     108    {
     109        FileSystem fs = getFileSystemInstance(dir);
     110        boolean created_dir = false;
     111
     112        if (!exists(dir)) {
     113            try {
     114                URI uri = new URI(dir);
     115                Path path = new Path(uri);
     116                fs.mkdirs(path);
     117                created_dir = true;
     118            } catch (URISyntaxException e) {
     119                e.printStackTrace();
     120            } catch (IOException e) {
     121                e.printStackTrace();
     122            }
     123        }
     124       
     125        return created_dir;
     126    }
     127   
     128    public static BufferedInputStream getBufferedInputStream(String fileIn)
    103129            throws IOException
    104130    {
     
    137163    }
    138164
    139     protected static BufferedOutputStream getBufferedOutputStream(String fileOut)
     165    public static BufferedOutputStream getBufferedOutputStream(String fileOut)
    140166            throws IOException
    141167    {
     
    163189    }
    164190   
    165     protected static BufferedReader getBufferedReaderForCompressedFile(String fileIn)
     191    public static BufferedReader getBufferedReaderForCompressedFile(String fileIn)
    166192            throws IOException, CompressorException
    167193    {
     
    172198    }
    173199
    174     protected static BufferedWriter getBufferedWriterForCompressedFile(String fileOut)
     200    public static BufferedWriter getBufferedWriterForCompressedFile(String fileOut)
    175201            throws IOException, CompressorException
    176202    {
Note: See TracChangeset for help on using the changeset viewer.