Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**
     * Convert integer wraped in string to int safely.
     */
    public static int toIntSafely(String text) {
        int result = -1;

        text = text.trim();
        try {
            result = Integer.parseInt(text);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }

        return result;
    }
}