Example usage for java.io IOException getLocalizedMessage

List of usage examples for java.io IOException getLocalizedMessage

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:fr.cs.examples.propagation.VisibilityCircle.java

/** Program entry point.
 * @param args program arguments/* w w  w .jav  a  2 s.c o m*/
 */
public static void main(String[] args) {
    try {

        // configure Orekit
        Autoconfiguration.configureOrekit();

        // input/out
        File input = new File(VisibilityCircle.class.getResource("/visibility-circle.in").toURI().getPath());
        File output = new File(input.getParentFile(), "visibility-circle.csv");

        new VisibilityCircle().run(input, output, ",");

        System.out.println("visibility circle saved as file " + output);

    } catch (URISyntaxException use) {
        System.err.println(use.getLocalizedMessage());
        System.exit(1);
    } catch (IOException ioe) {
        System.err.println(ioe.getLocalizedMessage());
        System.exit(1);
    } catch (IllegalArgumentException iae) {
        System.err.println(iae.getLocalizedMessage());
        System.exit(1);
    } catch (OrekitException oe) {
        System.err.println(oe.getLocalizedMessage());
        System.exit(1);
    }
}

From source file:com.googlecode.jgenhtml.JGenHtml.java

/**
 * Run jgenhtml.//  w  w w  .j a  v  a2  s .  c  om
 * @param argv Arguments (viewable by running with -h switch).
 */
public static void main(final String[] argv) {

    Config config = new Config();
    try {
        config.initializeUserPrefs(argv);
        if (config.isHelp()) {
            config.showCmdLineHelp();
        } else if (config.isVersion()) {
            System.out.println("jgenhtml version " + VERSION);
        } else {
            String[] traceFiles = config.getTraceFiles();
            if (traceFiles.length > 0) {
                CoverageReport.setConfig(config);
                CoverageReport coverageReport = new CoverageReport(traceFiles);
                if (coverageReport.getPageCount() > 0) {
                    LOGGER.log(Level.INFO, "Found {0} entries.", coverageReport.getPageCount());
                    coverageReport.generateReports();
                }
            } else {
                LOGGER.log(Level.INFO, "jgenhtml: No filename specified");
                LOGGER.log(Level.INFO, "Use jgenhtml --help to get usage information");
            }
        }
    } catch (IOException ex) {
        LOGGER.log(Level.SEVERE, null, ex);
    } catch (ParserConfigurationException ex) {
        LOGGER.log(Level.SEVERE, null, ex);
    } catch (ParseException ex) {
        LOGGER.log(Level.WARNING, ex.getLocalizedMessage());
    }
}

From source file:com.blackboard.WebdavBulkDeleterClient.java

public static void main(String[] args) {
    if (System.getProperty("log4j.configuration") != null) {
        PropertyConfigurator.configure(System.getProperty("log4j.configuration"));
    } else {//  w ww . j a v a  2s . com
        BasicConfigurator.configure();
    }

    // Perform command line parsing in an as friendly was as possible. 
    // Could be improved
    CommandLineParser parser = new PosixParser();
    Options options = new Options();

    // Use a map to store our options and loop over it to check and parse options via
    // addAllOptions() and verifyOptions() below
    Map<String, String> optionsAvailable = new HashMap<String, String>();
    optionsAvailable.put("deletion-list", "The file containing the list of courses to delete");
    optionsAvailable.put("user", "User with deletion privileges, usually bbsupport");
    optionsAvailable.put("password", "Password - ensure you escape any shell characters");
    optionsAvailable.put("url", "The Learn URL - usually https://example.com/bbcswebdav/courses");

    options = addAllOptions(options, optionsAvailable);

    options.addOption(OptionBuilder.withLongOpt("no-verify-ssl").withDescription("Don't verify SSL")
            .hasArg(false).create());

    CommandLine line = null;
    try {
        line = parser.parse(options, args);
        verifyOptions(line, optionsAvailable);
    } catch (ParseException e) {
        // Detailed reason will be printed by verifyOptions above
        logger.fatal("Incorrect options specified, exiting...");
        System.exit(1);
    }

    Scanner scanner = null;
    try {
        scanner = new Scanner(new File(line.getOptionValue("deletion-list")));
    } catch (FileNotFoundException e) {
        logger.fatal("Cannot open file : " + e.getLocalizedMessage());
        System.exit(1);
    }

    // By default we verify SSL certs
    boolean verifyCertStatus = true;
    if (line.hasOption("no-verify-ssl")) {
        verifyCertStatus = false;
    }

    // Loop through deletion list and delete courses if they exist.
    LearnServer instance;
    try {
        logger.debug("Attempting to open connection");
        instance = new LearnServer(line.getOptionValue("user"), line.getOptionValue("password"),
                line.getOptionValue("url"), verifyCertStatus);
        String currentCourse = null;
        logger.debug("Connection open");
        while (scanner.hasNextLine()) {
            currentCourse = scanner.nextLine();
            if (instance.exists(currentCourse)) {
                try {
                    instance.deleteCourse(currentCourse);
                    logger.info("Processing " + currentCourse + " : Result - Deletion Successful");
                } catch (IOException ioe) {
                    logger.error("Processing " + currentCourse + " : Result - Could not Delete ("
                            + ioe.getLocalizedMessage() + ")");
                }
            } else {
                logger.info("Processing " + currentCourse + " : Result - Course does not exist");
            }
        }
    } catch (IllegalArgumentException e) {
        logger.fatal(e.getLocalizedMessage());
        System.exit(1);
    } catch (IOException ioe) {
        logger.debug(ioe);
        logger.fatal(ioe.getMessage());
    }

}

From source file:fr.cs.examples.frames.Frames3.java

public static void main(String[] args) {
    try {// w  ww. j  av a2 s.  c  o m

        // configure Orekit and printing format
        Autoconfiguration.configureOrekit();

        // Initial state definition :
        // ==========================

        // Date
        // ****
        AbsoluteDate initialDate = new AbsoluteDate(new DateComponents(1970, 04, 07), TimeComponents.H00,
                TimeScalesFactory.getUTC());

        // Orbit
        // *****
        // The Sun is in the orbital plane for raan ~ 202
        double mu = 3.986004415e+14; // gravitation coefficient
        Frame eme2000 = FramesFactory.getEME2000(); // inertial frame
        Orbit orbit = new CircularOrbit(7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(50.),
                FastMath.toRadians(220.), FastMath.toRadians(5.300), PositionAngle.MEAN, eme2000, initialDate,
                mu);

        // Attitude laws
        // *************

        // Earth
        Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
        BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
                Constants.WGS84_EARTH_FLATTENING, earthFrame);

        // Target pointing attitude provider over satellite nadir at date, without yaw compensation
        NadirPointing nadirLaw = new NadirPointing(eme2000, earth);

        // Target pointing attitude provider with yaw compensation
        final PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
        YawSteering yawSteeringLaw = new YawSteering(eme2000, nadirLaw, sun, Vector3D.MINUS_I);

        // Propagator : Eckstein-Hechler analytic propagator
        Propagator propagator = new EcksteinHechlerPropagator(orbit, yawSteeringLaw,
                Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU,
                Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40,
                Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);

        // Let's write the results in a file in order to draw some plots.
        propagator.setMasterMode(10, new OrekitFixedStepHandler() {

            PrintStream out = null;

            public void init(SpacecraftState s0, AbsoluteDate t) throws PropagationException {
                try {
                    File file = new File(System.getProperty("user.home"), "XYZ.dat");
                    System.out.println("Results written to file: " + file.getAbsolutePath());
                    out = new PrintStream(file);
                    out.println("#time X Y Z Wx Wy Wz");
                } catch (IOException ioe) {
                    throw new PropagationException(ioe, LocalizedFormats.SIMPLE_MESSAGE,
                            ioe.getLocalizedMessage());
                }
            }

            public void handleStep(SpacecraftState currentState, boolean isLast) throws PropagationException {
                try {

                    // get the transform from orbit/attitude reference frame to spacecraft frame
                    Transform inertToSpacecraft = currentState.toTransform();

                    // get the position of the Sun in orbit/attitude reference frame
                    Vector3D sunInert = sun.getPVCoordinates(currentState.getDate(), currentState.getFrame())
                            .getPosition();

                    // convert Sun position to spacecraft frame
                    Vector3D sunSat = inertToSpacecraft.transformPosition(sunInert);

                    // and the spacecraft rotational rate also
                    Vector3D spin = inertToSpacecraft.getRotationRate();

                    // Lets calculate the reduced coordinates
                    double sunX = sunSat.getX() / sunSat.getNorm();
                    double sunY = sunSat.getY() / sunSat.getNorm();
                    double sunZ = sunSat.getZ() / sunSat.getNorm();

                    out.format(Locale.US, "%s %12.3f %12.3f %12.3f %12.7f %12.7f %12.7f%n",
                            currentState.getDate(), sunX, sunY, sunZ, spin.getX(), spin.getY(), spin.getZ());

                    if (isLast) {
                        out.close();
                    }
                } catch (OrekitException oe) {
                    throw new PropagationException(oe);
                }
            }

        });

        System.out.println("Running...");
        propagator.propagate(initialDate.shiftedBy(6000));

    } catch (OrekitException oe) {
        System.err.println(oe.getMessage());
    }
}

From source file:fr.cs.examples.propagation.TrackCorridor.java

/** Program entry point.
 * @param args program arguments/*from w w w  . j  a  v a  2s  . c  o  m*/
 */
public static void main(String[] args) {
    try {

        // configure Orekit
        Autoconfiguration.configureOrekit();

        // input/out
        File input = new File(TrackCorridor.class.getResource("/track-corridor.in").toURI().getPath());
        File output = new File(input.getParentFile(), "track-corridor.csv");

        new TrackCorridor().run(input, output, ",");

        System.out.println("corridor saved as file " + output);

    } catch (URISyntaxException use) {
        System.err.println(use.getLocalizedMessage());
        System.exit(1);
    } catch (IOException ioe) {
        System.err.println(ioe.getLocalizedMessage());
        System.exit(1);
    } catch (IllegalArgumentException iae) {
        System.err.println(iae.getLocalizedMessage());
        System.exit(1);
    } catch (OrekitException oe) {
        System.err.println(oe.getLocalizedMessage());
        System.exit(1);
    }
}

From source file:fr.cs.examples.propagation.DSSTPropagation.java

/** Program entry point.
 * @param args program arguments/* w  w  w . j ava  2  s .co  m*/
 */
public static void main(String[] args) {
    try {

        // configure Orekit data acces
        Utils.setDataRoot("tutorial-orekit-data");

        // input/output (in user's home directory)
        File input = new File(new File(System.getProperty("user.home")), "dsst-propagation.in");
        File output = new File(input.getParentFile(), "dsst-propagation.out");

        new DSSTPropagation().run(input, output);

    } catch (IOException ioe) {
        System.err.println(ioe.getLocalizedMessage());
        System.exit(1);
    } catch (IllegalArgumentException iae) {
        System.err.println(iae.getLocalizedMessage());
        System.exit(1);
    } catch (OrekitException oe) {
        System.err.println(oe.getLocalizedMessage());
        System.exit(1);
    } catch (ParseException pe) {
        System.err.println(pe.getLocalizedMessage());
        System.exit(1);
    }
}

From source file:fr.cs.examples.bodies.Phasing.java

/** Program entry point.
 * @param args program arguments//w ww .  ja  v a 2s  . c  o m
 */
public static void main(String[] args) {
    try {

        if (args.length != 1) {
            System.err.println("usage: java fr.cs.examples.bodies.Phasing filename");
            System.exit(1);
        }

        // configure Orekit
        Autoconfiguration.configureOrekit();

        // input/out
        URL url = Phasing.class.getResource("/" + args[0]);
        if (url == null) {
            System.err.println(args[0] + " not found");
            System.exit(1);
        }
        File input = new File(url.toURI().getPath());

        new Phasing().run(input);

    } catch (URISyntaxException use) {
        System.err.println(use.getLocalizedMessage());
        System.exit(1);
    } catch (IOException ioe) {
        System.err.println(ioe.getLocalizedMessage());
        System.exit(1);
    } catch (IllegalArgumentException iae) {
        iae.printStackTrace(System.err);
        System.err.println(iae.getLocalizedMessage());
        System.exit(1);
    } catch (ParseException pe) {
        System.err.println(pe.getLocalizedMessage());
        System.exit(1);
    } catch (OrekitException oe) {
        oe.printStackTrace(System.err);
        System.err.println(oe.getLocalizedMessage());
        System.exit(1);
    }
}

From source file:Main.java

/**
 * Get file content by filename/*from ww  w.jav a  2s  .  co  m*/
 * 
 * @param c
 * @param filename
 * @return content String
 */
public static String getFileContent(Context c, String filename) {
    try {
        InputStream fin = c.getAssets().open(filename);
        byte[] buffer = new byte[fin.available()];
        fin.read(buffer);
        fin.close();
        return new String(buffer);
    } catch (IOException e) {
        Log.e("inspector", e.getLocalizedMessage());
    }
    return "";
}

From source file:Main.java

public static String getJsonCurrencyObject(String myurl) {
    StringBuilder strBuilder = new StringBuilder();

    try {//from www .  j  a  va  2 s  . co  m
        URL url = new URL(myurl);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();

        InputStream inputStream = new BufferedInputStream(connection.getInputStream());

        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        String line;
        while ((line = reader.readLine()) != null) {
            strBuilder.append(line);
        }
        inputStream.close();

    } catch (MalformedURLException ex) {
        Log.d("HttpURLConnection", "getJsonCurrencyObject: " + ex.getMessage());
    }

    catch (IOException e) {
        Log.d("readJSONFeed", e.getLocalizedMessage());
        e.printStackTrace();
    } catch (Exception ex) {
        Log.d("GeneralException", ex.getMessage());
    }

    return strBuilder.toString();
}

From source file:Main.java

/**
 * This method gets the contact image from the phone book.
 * /*from w w  w  .jav  a  2s  .c  o  m*/
 * @param context
 * @param imageUri
 * @return Contact's image or null
 */
public static Bitmap getByteContactImage(Context context, String imageUri, int pixel) {
    if (imageUri == null) {
        return null;
    }
    if (imageUri != null) {
        try {
            Uri image_Uri = Uri.parse(imageUri);
            Bitmap bitmap = MediaStore.Images.Media.getBitmap(context.getContentResolver(), image_Uri);
            bitmap = Bitmap.createScaledBitmap(bitmap, pixel, pixel, false);
            return getRoundedCornerBitmap(bitmap, pixel);
        } catch (IOException e) {
            Log.e("EPollUtil", e.getLocalizedMessage());
        }
    }

    return null;
}