Example usage for java.io FileReader FileReader

List of usage examples for java.io FileReader FileReader

Introduction

In this page you can find the example usage for java.io FileReader FileReader.

Prototype

public FileReader(FileDescriptor fd) 

Source Link

Document

Creates a new FileReader , given the FileDescriptor to read, using the platform's java.nio.charset.Charset#defaultCharset() default charset .

Usage

From source file:edu.uci.ics.asterix.drivers.AsterixCLI.java

public static void main(String args[]) throws Exception {
    Options options = new Options();
    CmdLineParser parser = new CmdLineParser(options);
    parser.parseArgument(args);/*  ww w.  jav  a  2s.c om*/

    setUp(options);
    try {
        for (String queryFile : options.args) {
            Reader in = new FileReader(queryFile);
            AsterixJavaClient ajc = new AsterixJavaClient(
                    AsterixHyracksIntegrationUtil.getHyracksClientConnection(), in);
            try {
                ajc.compile(true, false, false, false, false, true, false);
            } finally {
                in.close();
            }
            ajc.execute();
        }
    } finally {
        tearDown();
    }
    System.exit(0);
}

From source file:CopyCharacters.java

public static void main(String[] args) throws IOException {
    FileReader inputStream = null;
    FileWriter outputStream = null;

    try {/* w  w w  .j  a va 2  s  .c om*/
        inputStream = new FileReader("xanadu.txt");
        outputStream = new FileWriter("characteroutput.txt");

        int c;
        while ((c = inputStream.read()) != -1) {
            outputStream.write(c);
        }
    } finally {
        if (inputStream != null) {
            inputStream.close();
        }
        if (outputStream != null) {
            outputStream.close();
        }
    }
}

From source file:Copy.java

public static void main(String[] args) throws IOException {
    File inputFile = new File("farrago.txt");
    File outputFile = new File("outagain.txt");

    FileReader in = new FileReader(inputFile);
    FileWriter out = new FileWriter(outputFile);
    int c;/*from  w  w  w.  ja  v  a2 s  . c o m*/

    while ((c = in.read()) != -1)
        out.write(c);

    in.close();
    out.close();
}

From source file:featureExtractor.popularityMeasure.java

public static void main(String[] args) throws IOException {
    //ReadKnownPopularityScores();
    FileWriter fw = new FileWriter(Out_resultFile);
    BufferedWriter bw = new BufferedWriter(fw);

    FileReader inputFile = new FileReader(In_entities);
    BufferedReader bufferReader = new BufferedReader(inputFile);
    String line;/*from  w  w w . ja v  a 2  s  .  c om*/
    while ((line = bufferReader.readLine()) != null) {
        String[] row = line.split("\t");
        double score = 0;
        String entityName = row[0].toLowerCase().trim();
        System.out.println("Searching for : " + entityName);
        if (knownScore_table.containsKey(entityName)) {
            //System.out.println("Already known for: " + entityName);
            score = knownScore_table.get(entityName);
        } else {
            System.out.println("Not known for: " + entityName);
            String json = searchTest(entityName, "&scoring=entity");
            try {
                score = ParseJSON_getScore(json);
            } catch (Exception e) {
                score = 0;
            }
            System.out.println("Putting : " + entityName);
            knownScore_table.put(entityName, score);
        }
        bw.write(row[0] + "\t" + score + "\n");
        System.out.println(row[0]);
    }
    bw.close();
}

From source file:fr.dutra.tools.maven.deptree.extras.VelocityRendererMain.java

/**
 * Arguments list:/*from  ww  w .j a  v a 2 s  . c  o m*/
 * <ol>
 * <li>Full path of dependency tree file to parse;</li>
 * <li>Dependency tree file format; must be the (case-insensitive) name of a <code>{@link InputType}</code> enum;</li>
 * <li>Full path to the output directory where HTML files and static resources will be generated (<em>this directory will be erased</em>);</li>
 * <li>Renderer format; must be the (case-insensitive) name of a <code>{@link VelocityRenderType}</code> enum;</li>
 * </ol>
 * @param args
 * @throws ParseException
 * @throws IOException
 * @throws VisitException
 */
public static void main(String[] args) throws IOException, ParseException, VisitException {
    InputType format = InputType.valueOf(args[1].toUpperCase());
    Parser parser = format.newParser();
    Node tree = parser.parse(new FileReader(args[0]));
    File outputDir = new File(args[2]);
    FileUtils.deleteDirectory(outputDir);
    outputDir.mkdirs();
    VelocityRenderer renderer = VelocityRenderType.valueOf(args[3].toUpperCase()).newRenderer();
    renderer.setFileName("index.html");
    renderer.setOutputDir(outputDir);
    renderer.visit(tree);
}

From source file:ch.qos.logback.decoder.cli.Main.java

/**
 * Entry point for command-line interface
 *
 * @param args the command-line parameters
 *//*from w  w w. j a va 2 s. c o  m*/
static public void main(String[] args) {
    MainArgs mainArgs = null;
    try {
        mainArgs = new MainArgs(args);

        // handle help and version queries
        if (mainArgs.queriedHelp()) {
            mainArgs.printUsage();
        } else if (mainArgs.queriedVersion()) {
            mainArgs.printVersion();

            // normal processing
        } else {
            if (mainArgs.isDebugMode()) {
                enableVerboseLogging();
            }

            BufferDecoder decoder = new BufferDecoder();
            decoder.setLayoutPattern(mainArgs.getLayoutPattern());

            BufferedReader reader = null;
            if (StringUtils.defaultString(mainArgs.getInputFile()).isEmpty()) {
                reader = new BufferedReader(new InputStreamReader(System.in));
            } else {
                reader = new BufferedReader(new FileReader(mainArgs.getInputFile()));
            }

            decoder.decode(reader);
        }
    } catch (Exception e) {
        System.err.println("error: " + e.getMessage());
    }
}

From source file:com.apipulse.bastion.Main.java

public static void main(String[] args) throws IOException, ClassNotFoundException {
    log.info("Bastion starting. Loading chains");
    final File dir = new File("etc/chains");

    final LinkedList<ActorRef> chains = new LinkedList<ActorRef>();
    for (File file : dir.listFiles()) {
        if (!file.getName().startsWith(".") && file.getName().endsWith(".yaml")) {
            log.info("Loading chain: " + file.getName());
            ChainConfig config = new ChainConfig(IOUtils.toString(new FileReader(file)));
            ActorRef ref = BastionActors.getInstance().initChain(config.getName(),
                    Class.forName(config.getQualifiedClass()));
            Iterator<StageConfig> iterator = config.getStages().iterator();
            while (iterator.hasNext())
                ref.tell(iterator.next(), null);
            chains.add(ref);/*from ww w. j  av a2 s. c o  m*/
        }
    }
    SpringApplication app = new SpringApplication();
    HashSet<Object> objects = new HashSet<Object>();
    objects.add(ApiController.class);
    final ConfigurableApplicationContext context = app.run(ApiController.class, args);
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            try {
                log.info("Bastion shutting down");
                Iterator<ActorRef> iterator = chains.iterator();
                while (iterator.hasNext())
                    iterator.next().tell(new StopMessage(), null);
                Thread.sleep(2000);
                context.stop();
                log.info("Bastion shutdown complete");
            } catch (Exception e) {
            }
        }
    });
}

From source file:CopyLines.java

public static void main(String[] args) throws IOException {
    BufferedReader inputStream = null;
    PrintWriter outputStream = null;

    try {/*w  ww  .j  a v a2 s  . c o  m*/
        inputStream = new BufferedReader(new FileReader("xanadu.txt"));
        outputStream = new PrintWriter(new FileWriter("characteroutput.txt"));

        String l;
        while ((l = inputStream.readLine()) != null) {
            outputStream.println(l);
        }
    } finally {
        if (inputStream != null) {
            inputStream.close();
        }
        if (outputStream != null) {
            outputStream.close();
        }
    }
}

From source file:BufferedCopy.java

public static void main(String[] args) throws IOException {
    BufferedReader inputStream = null;
    BufferedWriter outputStream = null;

    try {//from   w ww.j  a  v a2  s.c o m
        inputStream = new BufferedReader(new FileReader("xanadu.txt"));
        outputStream = new BufferedWriter(new FileWriter("characteroutput.txt"));

        int c;
        while ((c = inputStream.read()) != -1) {
            outputStream.write(c);
        }
    } finally {
        if (inputStream != null) {
            inputStream.close();
        }
        if (outputStream != null) {
            outputStream.close();
        }
    }
}

From source file:ZipDemo.java

public static void main(String[] args) throws Exception {
    for (int i = 0; i < args.length; ++i) {
        String uncompressed = "";
        File f = new File(args[i]);

        if (f.exists()) {
            BufferedReader br = new BufferedReader(new FileReader(f));

            String line = "";
            StringBuffer buffer = new StringBuffer();

            while ((line = br.readLine()) != null)
                buffer.append(line);/*www.j a v  a 2  s.c  o  m*/

            br.close();
            uncompressed = buffer.toString();
        } else {
            uncompressed = args[i];
        }

        byte[] compressed = ZipDemo.compress(uncompressed);

        String compressedAsString = new String(compressed);

        byte[] bytesFromCompressedAsString = compressedAsString.getBytes();

        bytesFromCompressedAsString.equals(compressed);
        System.out.println(ZipDemo.uncompress(compressed));
        System.out.println(ZipDemo.uncompress(compressedAsString));
    }
}