Java Code Examples for java.io.IOException.printStackTrace()

The following are Jave code examples for showing how to use printStackTrace() of the java.io.IOException class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: android-apps   File: JsoupUtil.java   View Source Code Vote up 7 votes
private static Map boluxsCatalog(Map map, String url) {
  try {
    List data = new ArrayList();
    Document document = Jsoup
        .connect(url)
        .userAgent(FormatUtil.USER_AGENT_PC)
        .get();
    Element body = document.body();
    Elements catalogEles = body.getElementsByClass("article_texttitleb").last().getElementsByTag("li");
    for (Element catalogE : catalogEles) {
      Map<String, Object> _map = new HashMap<>();
      _map.put("catalog", catalogE.text());
      _map.put("href", url + catalogE.getElementsByTag("a").attr("href"));
      data.add(_map);
    }
    String cover = body.getElementsByClass("img").first().getElementsByTag("img").first().attr("src");
    map.put("data", data);
    map.put("cover", cover);
    map.put("lastChapter", ((Map) data.get(data.size() - 1)).get("catalog").toString());
  } catch (IOException e) {
    e.printStackTrace();
  }
  return map;
}
 
Example 2
Project: Achtbaan   File: ConfigManager.java   View Source Code Vote up 6 votes
private int getCommentsNum(File file) {
    if (!file.exists())
        return 0;
    try {
        int comments = 0;
        String currentLine;

        BufferedReader reader = new BufferedReader(new FileReader(file));

        while ((currentLine = reader.readLine()) != null)
            if (currentLine.startsWith("#"))
                comments++;

        reader.close();
        return comments;
    } catch (IOException e) {
        e.printStackTrace();
        return 0;
    }
}
 
Example 3
Project: Transwarp-Sample-Code   File: Delete.java   View Source Code Vote up 6 votes
public static void main(String[] args) {
    String rootPath = "hdfs://nameservice1";
    Path p = new Path(rootPath + "/tmp/file.txt");
    Configuration conf = new Configuration();
    conf.addResource("core-site.xml");
    conf.addResource("hdfs-site.xml");
    conf.addResource("yarn-site.xml");
    try {
        // 没开kerberos,注释下面两行
        UserGroupInformation.setConfiguration(conf);
        UserGroupInformation.loginUserFromKeytab("[email protected]","E:\\星环\\hdfs.keytab");
        FileSystem fs = p.getFileSystem(conf);
        boolean b = fs.delete(p, true);
        System.out.println(b);
        fs.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 4
Project: reading-and-annotate-rocketmq-3.4.6   File: RemotingUtil.java   View Source Code Vote up 6 votes
public static SocketChannel connect(SocketAddress remote, final int timeoutMillis) {
    SocketChannel sc = null;
    try {
        sc = SocketChannel.open();
        sc.configureBlocking(true);
        sc.socket().setSoLinger(false, -1);
        sc.socket().setTcpNoDelay(true);
        sc.socket().setReceiveBufferSize(1024 * 64);
        sc.socket().setSendBufferSize(1024 * 64);
        sc.socket().connect(remote, timeoutMillis);
        sc.configureBlocking(false);
        return sc;
    }
    catch (Exception e) {
        if (sc != null) {
            try {
                sc.close();
            }
            catch (IOException e1) {
                e1.printStackTrace();
            }
        }
    }

    return null;
}
 
Example 5
Project: ja-micro   File: RpcMethodScanner.java   View Source Code Vote up 6 votes
private List<RpcMethodDefinition> searchClasspath(String serviceName) {

        logger.info("Scanning classpath for proto files of {}", serviceName);

        List<RpcMethodDefinition> rpcMethodDefinitions = new ArrayList<>();
        String classpath = System.getProperty("java.class.path");
        String jars[] = classpath.split(":");
        for (String jar : jars) {
            try {
                rpcMethodDefinitions = searchJar(jar, serviceName);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (!rpcMethodDefinitions.isEmpty()) {
                break;
            }
        }
        return rpcMethodDefinitions;
    }
 
Example 6
Project: Hydroangeas   File: HubBalancer.java   View Source Code Vote up 6 votes
public boolean updateHubTemplate()
{
    try
    {
        hubTemplate = (SimpleGameTemplate) instance.getTemplateManager().getTemplateByID("hub");
        if (hubTemplate == null)
            throw new IOException("No Hub template found !");
    } catch (IOException e)
    {
        e.printStackTrace();
        instance.getLogger().severe("Add one and reboot HydroServer or no hub will be start on the network!");
        return false;
    }

    if (balancer == null)
    {
        balancer = new BalancingTask(instance, this);
    }

    if (!balancer.isAlive())
    {
        balancer.start();
    }
    return true;
}
 
Example 7
Project: TPlayer   File: PackageParserEx.java   View Source Code Vote up 6 votes
public static void readSignature(VPackage pkg) {
    File signatureFile = VEnvironment.getSignatureFile(pkg.packageName);
    if (!signatureFile.exists()) {
        return;
    }
    Parcel p = Parcel.obtain();
    try {
        FileInputStream fis = new FileInputStream(signatureFile);
        byte[] bytes = FileUtils.toByteArray(fis);
        fis.close();
        p.unmarshall(bytes, 0, bytes.length);
        p.setDataPosition(0);
        pkg.mSignatures = p.createTypedArray(Signature.CREATOR);
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        p.recycle();
    }
}
 
Example 8
Project: PekaED   File: EpisodePanel.java   View Source Code Vote up 6 votes
public void saveEpisode() {
	try {
		BufferedWriter w = new BufferedWriter(new FileWriter(Data.currentEpisodePath + File.separatorChar + Data.currentEpisodeFile.getName()));
		
		w.write(Data.currentEpisodeName + "\n");
		w.write(Data.currentEpisodePath + "\n");
		
		for (File f : Data.episodeFiles) {
			w.write(f.getAbsolutePath() + "\n");
		}
		
		w.flush();
		w.close();
		
		Data.episodeChanged = false;
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 9
Project: monarch   File: AbstractTierStoreReader.java   View Source Code Vote up 6 votes
/**
 * Get all ORC files present in directory for the specified table and partition/bucket. The ORC
 * files returned are in ascending order of the (insertion) time-partition and sequence-id within
 * the time-partition.
 *
 * @param orcDir the ORC store directory
 * @param args the arguments in order: table-name, bucket-id, time-partition-id
 * @return the list of all ORC files
 */
private String[] getOrcFiles(final String orcDir, final String fileExt, final String... args) {
  try {
    FileSystem fileSystem = FileSystem.get(conf);
    Path distributedPath = new Path(Paths.get(orcDir, args).toString());
    ArrayList<String> filePathStrings = new ArrayList<>();
    if (fileSystem.exists(distributedPath)) {
      RemoteIterator<LocatedFileStatus> fileListItr = fileSystem.listFiles(distributedPath, true);
      while (fileListItr != null && fileListItr.hasNext()) {
        LocatedFileStatus file = fileListItr.next();
        if (!file.getPath().getName().endsWith(fileExt)) {
          // exclude CRC files
          filePathStrings.add(file.getPath().toUri().toString());
        }
      }

      Collections.sort(filePathStrings);
    }
    String[] retArray = new String[filePathStrings.size()];
    filePathStrings.toArray(retArray);
    return retArray;
  } catch (IOException e) {
    e.printStackTrace();
  }
  return new String[0];
}
 
Example 10
Project: JGame   File: JGame.java   View Source Code Vote up 6 votes
@Override
public void create() {
	batch = new SpriteBatch();
	cam = new Camera(screenX, screenY);
	batch.setProjectionMatrix(cam.camera.combined);
	batch.enableBlending();
	try {
		save = new Save();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

	this.setScreen(new MainMenu(this));

}
 
Example 11
Project: tuxguitar   File: PTInputStream.java   View Source Code Vote up 5 votes
private void skip(int bytes){
	try {
		this.stream.read(new byte[bytes]);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
Example 12
Project: MFM   File: MFMController.java   View Source Code Vote up 5 votes
private void showHTML(String title, String path) {
        JScrollPane scrollPane = new JScrollPane();

/*  fixme Bug with HTML embedded URL Link
        HTMLtextPane.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseReleased(MouseEvent e) {
                super.mouseReleased(e);
                // createFontResizePopup().setVisible(true);
                createFontResizePopup().show(HTMLtextPane, 10, 10);
            }
        });
*/
        //    HTMLtextPane.add(createFontResizePopup());
        URL url;
        url = MFMUI_Resources.getInstance().ResourceURLs().get(path);
        try {
            HTMLtextPane.setPage(url);
        } catch (IOException e) {
            e.printStackTrace();
        }
        HTMLtextPane.setPreferredSize(new Dimension(850, 600));
        scrollPane.setViewportView(HTMLtextPane);
        // NOTE we do all of this to have a resizable dialog.
        Object[] array = {
                new JLabel(title),
                scrollPane,
        };
        JOptionPane pane = new JOptionPane(array, JOptionPane.PLAIN_MESSAGE);
        JDialog dialog = pane.createDialog(mainFrame, "");
        dialog.setLocation(150, 150);
        dialog.setResizable(true);
        dialog.setVisible(true);
    }
 
Example 13
Project: markor   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    _appSettings = new AppSettings(this);
    _contextUtils = new ActivityUtils(this);
    _contextUtils.setAppLanguage(_appSettings.getLanguage());
    if (_appSettings.isOverviewStatusBarHidden()) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    if (!_appSettings.isLoadLastDirectoryAtStartup()) {
        _appSettings.setLastOpenedDirectory(null);
    }
    setContentView(R.layout.main__activity);
    ButterKnife.bind(this);
    setSupportActionBar(_toolbar);

    optShowRate();

    try {
        if (_appSettings.isAppCurrentVersionFirstStart(true)) {
            SimpleMarkdownParser smp = SimpleMarkdownParser.get().setDefaultSmpFilter(SimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW);
            String html = "";
            html += smp.parse(getString(R.string.copyright_license_text_official).replace("\n", "  \n"), "").getHtml();
            html += "<br/><br/><br/><big><big>" + getString(R.string.changelog) + "</big></big><br/>" + smp.parse(getResources().openRawResource(R.raw.changelog), "", SimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW, SimpleMarkdownParser.FILTER_CHANGELOG);
            html += "<br/><br/><br/><big><big>" + getString(R.string.licenses) + "</big></big><br/>" + smp.parse(getResources().openRawResource(R.raw.licenses_3rd_party), "").getHtml();
            ActivityUtils _au = new ActivityUtils(this);
            _au.showDialogWithHtmlTextView(R.string.licenses, html);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    // Setup viewpager
    removeShiftMode(_bottomNav);
    _viewPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    _viewPager.setAdapter(_viewPagerAdapter);
    _bottomNav.setOnNavigationItemSelectedListener(this);
}
 
Example 14
Project: ec4e   File: EditorConfigContentProvider.java   View Source Code Vote up 5 votes
private EditorConfig parse(IDocument document) {
	final ErrorHandler errorHandler = ErrorHandler.THROWING;
	EditorConfigModelHandler handler = new LocationAwareModelHandler(PropertyTypeRegistry.default_(),
			Version.CURRENT, errorHandler);
	EditorConfigParser parser = EditorConfigParser.default_();
	try {
		parser.parse(Resources.ofString(EditorConfigConstants.EDITORCONFIG, document.get()), handler, errorHandler);
	} catch (IOException e) {
		e.printStackTrace();
	}
	return handler.getEditorConfig();
}
 
Example 15
Project: RunMap   File: LogDumper.java   View Source Code Vote up 5 votes
static InputStream dumpLog(){
    try {
        Process process = Runtime.getRuntime().exec("logcat *:D -d");
        Runtime.getRuntime().exec("logcat -c");
        return process.getInputStream();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 16
Project: Parallator   File: MainConfig.java   View Source Code Vote up 5 votes
public void save() {
    File workingDirectory = new File(System.getProperty("user.dir"));
    try {
        FileWriter wrt = new FileWriter(new File(workingDirectory, ".config"));
        wrt.append(new Gson().toJson(this));
        wrt.flush();
        wrt.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 17
Project: incubator-netbeans   File: Alignment.java   View Source Code Vote up 5 votes
public void m(int a) {
    if (a == 1) {
    } else {
    }
    do {
    } while (a != 0);
    try {
        new FileReader("");
    } catch (IOException ioe) {
        ioe.printStackTrace();
    } finally {
    }

}
 
Example 18
Project: letv   File: DataUtils.java   View Source Code Vote up 4 votes
public static long getMemoryTotalSize() {
    Exception e;
    Throwable th;
    long mTotal = 0;
    String content = null;
    BufferedReader br = null;
    try {
        BufferedReader br2 = new BufferedReader(new FileReader("/proc/meminfo"), 8);
        try {
            String line = br2.readLine();
            if (line != null) {
                content = line;
            }
            if (!TextUtils.isEmpty(content)) {
                mTotal = (long) (Integer.parseInt(content.substring(content.indexOf(58) + 1, content.indexOf(107)).trim()) / 1024);
            }
            if (br2 != null) {
                try {
                    br2.close();
                    br = br2;
                } catch (IOException e2) {
                    e2.printStackTrace();
                    br = br2;
                }
            }
        } catch (Exception e3) {
            e = e3;
            br = br2;
            try {
                e.printStackTrace();
                if (br != null) {
                    try {
                        br.close();
                    } catch (IOException e22) {
                        e22.printStackTrace();
                    }
                }
                return mTotal;
            } catch (Throwable th2) {
                th = th2;
                if (br != null) {
                    try {
                        br.close();
                    } catch (IOException e222) {
                        e222.printStackTrace();
                    }
                }
                throw th;
            }
        } catch (Throwable th3) {
            th = th3;
            br = br2;
            if (br != null) {
                br.close();
            }
            throw th;
        }
    } catch (Exception e4) {
        e = e4;
        e.printStackTrace();
        if (br != null) {
            br.close();
        }
        return mTotal;
    }
    return mTotal;
}
 
Example 19
Project: trashjam2017   File: Game.java   View Source Code Vote up 4 votes
@Override
public void init(GameContainer arg0, StateBasedGame arg1) throws SlickException {
    player = new Player();
    buildings = new ArrayList<>();
    goons = new ArrayList<>();
    bullets = new ArrayList<>();
    playerImage = new Image("res/player.png");
    playerImage.setFilter(Image.FILTER_NEAREST);
    playerJump = new Image("res/playerjump.png");
    playerJump.setFilter(Image.FILTER_NEAREST);
    cannonImage = new Image("res/cannon.png");
    cannonImage.setFilter(Image.FILTER_LINEAR);
    cannonImage.setCenterOfRotation(Player.CANNON_CENTER_X, Player.CANNON_CENTER_Y);
    SpriteSheet playerSS = new SpriteSheet("res/player_run.png", 60, 75);
    playerRunRight = new Animation(playerSS, RUN_ANIMATION_SPEED);
    playerRunLeft  = new Animation();
    int ssw = playerSS.getHorizontalCount(), ssh = playerSS.getVerticalCount();
    for (int y = 0; y < ssh; y++) {
        for (int x = 0; x < ssw; x++) {
            playerRunLeft.addFrame(playerSS.getSprite(x, y).getFlippedCopy(true, false), RUN_ANIMATION_SPEED);
        }
    }
    bulletAnim = new Animation(new SpriteSheet("res/bullet.png", 30, 30), BULLET_ANIMATION_SPEED);
    buildingTexture = new Image("res/building.png");
    buildingLastRow = buildingTexture.getSubImage(0, buildingTexture.getHeight() - 1, buildingTexture.getWidth(), 1);
    buildingTexture.setFilter(Image.FILTER_NEAREST);
    buildingLastRow.setFilter(Image.FILTER_NEAREST);
    graffitiImages = new Image[NUM_GRAFFITI * 2];
    for (int i = 0; i < NUM_GRAFFITI; i++) {
        graffitiImages[i] = new Image("res/graffiti" + i + ".png");
        graffitiImages[i + NUM_GRAFFITI] = graffitiImages[i].getFlippedCopy(true, false);
    }
    graffiti = new ArrayList<>();
    mainTheme = new Music("res/main.ogg");
    try {
        partsys = ParticleIO.loadConfiguredSystem("res/particle.xml");
    } catch (IOException e) {
        e.printStackTrace();
    }
    fireExplosion = (ConfigurableEmitter)partsys.getEmitter(0);
    blueExplosion = (ConfigurableEmitter)partsys.getEmitter(1);
    fireExplosion.setEnabled(false);
    blueExplosion.setEnabled(false);
    fireCannon = new Sound("res/firecannon.ogg");
    highExplosion = new Sound("res/highexplosion.ogg");
    softExplosion = new Sound("res/softexplosion.ogg");
    hurtSound = new Sound("res/hurt.ogg");
    basicGoon = new Image("res/plasticbag.png");
    strongGoon = new Image("res/trashbag.png");
    flyingGoon = new Animation(new SpriteSheet("res/tshirt.png", 50, 50), 200);
    background = new Image("res/sunset.png");
    background.setFilter(Image.FILTER_NEAREST);
    camx = 0;
    camy = 0;
    camvx = 0;
}
 
Example 20
Project: MinimalismJotter   File: RecoderManager.java   View Source Code Vote up 4 votes
public static void voicePlay(final MediaPlayer player, String path, final SeekBar seekBar, final Chronometer chronometer) {
    if (player != null) {
        setChronometer(chronometer, Constant.CHRONOMETER_START);
        if (!isPlaying) {
            player.setAudioStreamType(AudioManager.STREAM_MUSIC);
            try {
                player.setDataSource(path);
                player.prepare();
            } catch (IOException e) {
                e.printStackTrace();
            }
            isPlaying = true;
        }


        player.start();

        //设置Bar的最大值
        int max = player.getDuration();
        seekBar.setMax(max);
        //定时器更新进度条
        final Timer timer = new Timer();
        TimerTask timeTask = new TimerTask() {
            @Override
            public void run() {
                // TODO Auto-generated method stub
                int a = player.getCurrentPosition();
                seekBar.setProgress(player.getCurrentPosition());
            }
        };
        timer.schedule(timeTask, 0, 500);

    /*player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

        public void onPrepared(MediaPlayer mp) {
            // TODO Auto-generated method stub
            player.start();
            seekBar.setMax(player.getDuration());
            seekBar.setEnabled(true);
        }
    });*/

        //音频播放完之后重新设置显示
        player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                // TODO Auto-generated method stub
                seekBar.setProgress(0);
                setChronometer(chronometer, Constant.CHRONOMETER_RESET);
                timer.cancel();
            }
        });
    }
}