Example usage for java.io FileNotFoundException getMessage

List of usage examples for java.io FileNotFoundException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.aliyun.odps.mapred.cli.Cli.java

public static void main(String[] args) {
    SessionState ss = SessionState.get();
    OptionParser parser = new OptionParser(ss);
    try {/*w w w.  j a va  2  s.  c  o m*/
        parser.parse(args);
    } catch (FileNotFoundException e) {
        System.err.println(e.getMessage());
        System.exit(-1);
    } catch (ClassNotFoundException e) {
        System.err.println("Class not found:" + e.getMessage());
        System.exit(-1);
    } catch (ParseException e) {
        System.err.println(e.getMessage());
        parser.usage();
        System.exit(-1);
    } catch (OdpsException e) {
        System.err.println(e.getMessage());
        System.exit(-1);
    }

    try {
        Method main = parser.getMainClass().getMethod("main", String[].class);
        main.invoke(null, (Object) parser.getArguments());
    } catch (InvocationTargetException e) {
        Throwable t = e.getCause();
        if (t != null && t instanceof OdpsException) {
            OdpsException ex = (OdpsException) t;
            System.err.println(ex.getErrorCode() + ":" + ex.getMessage());
            System.exit(-1);
        } else {
            throw new RuntimeException("Unknown error", e);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:DropReceivedLines.java

public static void main(String[] av) {
    DropReceivedLines d = new DropReceivedLines();
    // For stdin, act as a filter. For named files,
    // update each file in place (safely, by creating a new file).
    try {//www  .  ja v  a2s .  c o m
        if (av.length == 0)
            d.process(new BufferedReader(new InputStreamReader(System.in)), new PrintWriter(System.out));
        else
            for (int i = 0; i < av.length; i++)
                d.process(av[i]);
    } catch (FileNotFoundException e) {
        System.err.println(e.getMessage());
    } catch (IOException e) {
        System.err.println("I/O error " + e);
    }
}

From source file:ObjectTest.java

public static void main(String args[]) {
    for (int a = 0; a < args.length; a++) {
        String version = "Unknown";
        try {/*from   w w w .  j  a va2s. c o m*/
            JSONTokener tokener = new JSONTokener(new FileInputStream(args[a]));
            JSONObject jsonSubject = new JSONObject(tokener);
            version = jsonSubject.getJSONObject("X3D").getString("@version");
            JSONObject jsonSchema = new JSONObject(new JSONTokener(
                    ObjectTest.class.getResourceAsStream("x3d-" + version + "-JSONSchema.json")));

            Schema schema = SchemaLoader.load(jsonSchema);
            schema.validate(jsonSubject);

            // System.out.println("json-schema "+version+" Valid "+args[a]);
        } catch (NullPointerException npe) {
            System.out.println("json-config " + version + " null point error " + args[a]);
        } catch (FileNotFoundException e) {
            System.out.println("json-file file missing " + e.getMessage() + " " + args[a]);
        } catch (NumberFormatException nfe) {
            System.out.println("json-parse json " + nfe.getMessage() + " " + args[a]);
        } catch (JSONException je) {
            System.out.println("json-parse json " + je.getMessage() + " " + args[a]);
        } catch (ValidationException ve) {
            Iterator<ValidationException> i = ve.getCausingExceptions().iterator();
            while (i.hasNext()) {
                ValidationException veel = i.next();
                System.out.println("json-schema " + version + " Validation error " + veel + " " + args[a]);
            }
        }
    }
}

From source file:mjc.ARMMain.java

public static void main(String[] args) {

    for (String arg : args) {
        if (!arg.startsWith("-")) { // ignore flags
            try {
                File in = new File(arg);
                File out = new File(FilenameUtils.removeExtension(in.getName()) + ".s");
                compile(new FileInputStream(in), new PrintStream(out));
            } catch (FileNotFoundException e) {
                System.err.println("Error: " + e.getMessage());
                System.exit(1);/*from w  w  w  .  j  ava 2 s . c o  m*/
            } catch (Throwable t) {
                System.err.println("Could not compile: " + t.getMessage());
                System.exit(1);
            }
        }
    }

    // All went well, exit with status 0.
    System.exit(0);

}

From source file:com.mmone.gpdati.allotment.reader.AllotmentFileReader.java

public static void main(String[] args) {
    try {//w  w  w  .jav a  2  s.c  o  m
        AllotmentLineProvvider afr = new AllotmentFileReader(
                "C:/svnprjects/mauro_netbprj/abs-ota-soapui-listener/test/FILE_DISPO__20160616.txt");

        List<String> l = afr.getLines();
        for (String s : l) {
            System.out.println(s);
        }
    } catch (FileNotFoundException ex) {
        Logger.getLogger(AllotmentFileReader.class.getName()).log(Level.INFO,
                "skipping sync " + ex.getMessage());
    } catch (Exception ex) {
        Logger.getLogger(AllotmentFileReader.class.getName()).log(Level.INFO,
                "skipping sync " + ex.getMessage());
        Logger.getLogger(AllotmentFileReader.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:de.tudarmstadt.ukp.teaching.uima.nounDecompounding.ranking.FrequencyBased.java

public static void main(String[] args) {
    CommandLine cmd = AbstractRanker.parseArgs(args);
    if (cmd == null) {
        return;/*from  www .j  av  a 2s. c om*/
    }

    int limit = AbstractRanker.getLimitOption(cmd);
    String indexPath = AbstractRanker.getIndexPathOption(cmd);

    // Setup
    IDictionary dict = new IGerman98Dictionary(new File("src/main/resources/de_DE.dic"),
            new File("src/main/resources/de_DE.aff"));
    LinkingMorphemes morphemes = new LinkingMorphemes(new File("src/main/resources/linkingMorphemes.txt"));
    LeftToRightSplitAlgorithm splitter = new LeftToRightSplitAlgorithm(dict, morphemes);

    FrequencyBased ranker = new FrequencyBased(new Finder(new File(indexPath)));

    // Execute
    try {
        RankingEvaluation e = new RankingEvaluation(
                new CcorpusReader(new File("src/main/resources/evaluation/ccorpus.txt")));
        RankingEvaluation.Result[] result = e.evaluateListAndTree(splitter, ranker, limit);

        // Print result
        System.out.println("List:");
        System.out.println(result[0].toString());
        System.out.println("Tree:");
        System.out.println(result[1].toString());
    } catch (FileNotFoundException e1) {
        System.err.println("Error: " + e1.getMessage());
        e1.printStackTrace();
    }
}

From source file:be.vdab.util.Programma.java

public static void main(String[] args) {
    SortedSet<Voertuig> voertuigen = new TreeSet<Voertuig>();
    Datum datum = null;/*  ww w  .  j a v a 2  s.  c  o m*/
    Volume volumePickup = null;
    Volume volumeVrachtwagen = null;
    try {
        datum = new Datum(21, 11, 2012);
    } catch (DatumException de) {
        System.out.println(de.getMessage());
    }
    Mens bestuurder_BC = new Mens("Albert", Rijbewijs.B, Rijbewijs.C);
    Mens inzittende_A = new Mens("Karolien", Rijbewijs.A);
    Mens inzittende = new Mens("Zora");
    Mens inzittende_B = new Mens("David", Rijbewijs.B);
    Mens inzittende_DDE = new Mens("Evert", Rijbewijs.D, Rijbewijs.DE);
    Mens bestuurder_DE = new Mens("Boris", Rijbewijs.DE);
    Personenwagen wagen1Opel = new Personenwagen("Opel", datum, 250000, 4, Color.blue, bestuurder_BC,
            inzittende_A, inzittende);
    Personenwagen wagen2 = new Personenwagen("Mazda", datum, 27000, 5, Color.blue, bestuurder_BC, inzittende_A);

    try {
        volumePickup = new Volume(3, 3, 2, Maat.meter);
        volumeVrachtwagen = new Volume(3, 6, 2, Maat.meter);
    } catch (VolumeException ve) {
        System.out.println(ve.getMessage());
    }

    Pickup pickup1Opel = new Pickup("Opel", datum, 400000, 5, Color.RED, volumePickup, bestuurder_BC,
            inzittende_B, inzittende_DDE, inzittende_A);
    Pickup pickup2 = new Pickup("Toyota", datum, 39000, 4, Color.blue, volumePickup, bestuurder_BC);
    Vrachtwagen vrachtwagen1 = new Vrachtwagen("BMW", datum, 90000, 2, volumeVrachtwagen, 3000, 6,
            bestuurder_BC, inzittende_A);
    Vrachtwagen vrachtwagen2 = new Vrachtwagen("Mercedes", datum, 120000, 3, volumeVrachtwagen, 2000, 8,
            bestuurder_BC, inzittende);
    voertuigen.add(wagen1Opel); //gesorteerd op nummerplaat
    voertuigen.add(wagen2);
    voertuigen.add(pickup1Opel);
    voertuigen.add(pickup2);
    voertuigen.add(vrachtwagen1);
    voertuigen.add(vrachtwagen2);

    print(voertuigen);

    /*
    //copy manier1
    //copy (niet nodig dadelijk naar list omzetten, maar dan zit het niet in een SortedSet, oplossing: zelf copy uitvoeren, maar niet enkel referenties
    Set<Voertuig> voertuigen2=null;//=new TreeSet<Voertuig>(voertuigen); //new TreeSet<Voertuig>( org.apache.commons.collections.ComparatorUtils.reversedComparator( Voertuig.getAankoopprijsComparator()));
    //transformeren naar List, ook een copy
    List<Voertuig> lijst=new ArrayList<Voertuig>(voertuigen);//niet voertuigen 2
    //sort
      Collections.sort(lijst, org.apache.commons.collections.ComparatorUtils.reversedComparator( Voertuig.getAankoopprijsComparator()));
      print(lijst);
    */
    Set<Voertuig> voertuigen2 = new TreeSet<Voertuig>(org.apache.commons.collections.ComparatorUtils
            .reversedComparator(Voertuig.getAankoopprijsComparator()));
    voertuigen2.addAll(voertuigen);
    print(voertuigen2);

    //Copy manier 2: beter
    Set<Voertuig> voertuigen3 = new TreeSet<Voertuig>(Voertuig.getMerkComparator());
    voertuigen3.addAll(voertuigen);//deep copy of niet , staat niet in de api. Maakt het uit hier? wanneer wel?als je de vrachtwagens gaat wijzigen en je wil dat die alleen in de copy gewijzigd zijn dan deep copy nodig
    print(voertuigen3);

    try {
        schrijweg((TreeSet) voertuigen3, "wagenpark.ser");
    } catch (FileNotFoundException fnfe) {
        System.out.println(fnfe.getMessage());
    } catch (IOException ioe) {
        System.out.println(ioe.getMessage());
    }
    TreeSet<Voertuig> voertuigen4 = lees("wagenpark.ser");
    System.out.println("Voertuigen4");
    print(voertuigen4);

}

From source file:net.mybox.mybox.ServerSetup.java

/**
 * Handle command line arguments// w  ww  .j a  v a2 s  . c o  m
 * @param args
 */
public static void main(String[] args) {

    Options options = new Options();
    options.addOption("a", "apphome", true, "application home directory");
    options.addOption("h", "help", false, "show help screen");
    options.addOption("V", "version", false, "print the Mybox version");

    CommandLineParser line = new GnuParser();
    CommandLine cmd = null;

    try {
        cmd = line.parse(options, args);
    } catch (Exception exp) {
        System.err.println(exp.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(Server.class.getName(), options);
        return;
    }

    if (cmd.hasOption("h")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(Server.class.getName(), options);
        return;
    }

    if (cmd.hasOption("V")) {
        Server.printMessage("version " + Common.appVersion);
        return;
    }

    if (cmd.hasOption("a")) {
        String appHomeDir = cmd.getOptionValue("a");
        try {
            Common.updatePaths(appHomeDir);
        } catch (FileNotFoundException e) {
            Server.printErrorExit(e.getMessage());
        }

        Server.updatePaths();
    }

    ServerSetup setup = new ServerSetup();
}

From source file:examples.mail.java

public final static void main(String[] args) {
    String sender, recipient, subject, filename, server, cc;
    Vector ccList = new Vector();
    BufferedReader stdin;/* w  w  w . j  av a 2s . c  o m*/
    FileReader fileReader = null;
    Writer writer;
    SimpleSMTPHeader header;
    SMTPClient client;
    Enumeration en;

    if (args.length < 1) {
        System.err.println("Usage: mail smtpserver");
        System.exit(1);
    }

    server = args[0];

    stdin = new BufferedReader(new InputStreamReader(System.in));

    try {
        System.out.print("From: ");
        System.out.flush();

        sender = stdin.readLine();

        System.out.print("To: ");
        System.out.flush();

        recipient = stdin.readLine();

        System.out.print("Subject: ");
        System.out.flush();

        subject = stdin.readLine();

        header = new SimpleSMTPHeader(sender, recipient, subject);

        while (true) {
            System.out.print("CC <enter one address per line, hit enter to end>: ");
            System.out.flush();

            // Of course you don't want to do this because readLine() may be null
            cc = stdin.readLine().trim();

            if (cc.length() == 0)
                break;

            header.addCC(cc);
            ccList.addElement(cc);
        }

        System.out.print("Filename: ");
        System.out.flush();

        filename = stdin.readLine();

        try {
            fileReader = new FileReader(filename);
        } catch (FileNotFoundException e) {
            System.err.println("File not found. " + e.getMessage());
        }

        client = new SMTPClient();
        client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));

        client.connect(server);

        if (!SMTPReply.isPositiveCompletion(client.getReplyCode())) {
            client.disconnect();
            System.err.println("SMTP server refused connection.");
            System.exit(1);
        }

        client.login();

        client.setSender(sender);
        client.addRecipient(recipient);

        en = ccList.elements();

        while (en.hasMoreElements())
            client.addRecipient((String) en.nextElement());

        writer = client.sendMessageData();

        if (writer != null) {
            writer.write(header.toString());
            Util.copyReader(fileReader, writer);
            writer.close();
            client.completePendingCommand();
        }

        fileReader.close();

        client.logout();

        client.disconnect();
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:com.xiangzhurui.util.email.SMTPMail.java

public static void main(String[] args) {
    String sender, recipient, subject, filename, server, cc;
    List<String> ccList = new ArrayList<String>();
    BufferedReader stdin;//  w ww  .  j  a v  a  2 s.  co m
    FileReader fileReader = null;
    Writer writer;
    SimpleSMTPHeader header;
    SMTPClient client;

    if (args.length < 1) {
        System.err.println("Usage: mail smtpserver");
        System.exit(1);
    }

    server = args[0];

    stdin = new BufferedReader(new InputStreamReader(System.in));

    try {
        System.out.print("From: ");
        System.out.flush();

        sender = stdin.readLine();

        System.out.print("To: ");
        System.out.flush();

        recipient = stdin.readLine();

        System.out.print("Subject: ");
        System.out.flush();

        subject = stdin.readLine();

        header = new SimpleSMTPHeader(sender, recipient, subject);

        while (true) {
            System.out.print("CC <enter one address per line, hit enter to end>: ");
            System.out.flush();

            cc = stdin.readLine();

            if (cc == null || cc.length() == 0) {
                break;
            }

            header.addCC(cc.trim());
            ccList.add(cc.trim());
        }

        System.out.print("Filename: ");
        System.out.flush();

        filename = stdin.readLine();

        try {
            fileReader = new FileReader(filename);
        } catch (FileNotFoundException e) {
            System.err.println("File not found. " + e.getMessage());
        }

        client = new SMTPClient();
        client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out), true));

        client.connect(server);

        if (!SMTPReply.isPositiveCompletion(client.getReplyCode())) {
            client.disconnect();
            System.err.println("SMTP server refused connection.");
            System.exit(1);
        }

        client.login();

        client.setSender(sender);
        client.addRecipient(recipient);

        for (String recpt : ccList) {
            client.addRecipient(recpt);
        }

        writer = client.sendMessageData();

        if (writer != null) {
            writer.write(header.toString());
            Util.copyReader(fileReader, writer);
            writer.close();
            client.completePendingCommand();
        }

        if (fileReader != null) {
            fileReader.close();
        }

        client.logout();

        client.disconnect();
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    }
}