本文整理汇总了Java中java.io.IOException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java IOException.printStackTrace方法的具体用法?Java IOException.printStackTrace怎么用?Java IOException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.IOException
的用法示例。
在下文中一共展示了IOException.printStackTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: boluxsCatalog
import java.io.IOException; //导入方法依赖的package包/类
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;
}
示例2: getCommentsNum
import java.io.IOException; //导入方法依赖的package包/类
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;
}
}
示例3: main
import java.io.IOException; //导入方法依赖的package包/类
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();
}
}
示例4: connect
import java.io.IOException; //导入方法依赖的package包/类
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;
}
示例5: searchClasspath
import java.io.IOException; //导入方法依赖的package包/类
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;
}
示例6: updateHubTemplate
import java.io.IOException; //导入方法依赖的package包/类
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;
}
示例7: readSignature
import java.io.IOException; //导入方法依赖的package包/类
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();
}
}
示例8: saveEpisode
import java.io.IOException; //导入方法依赖的package包/类
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();
}
}
示例9: getOrcFiles
import java.io.IOException; //导入方法依赖的package包/类
/**
* 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];
}
示例10: create
import java.io.IOException; //导入方法依赖的package包/类
@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));
}
示例11: skip
import java.io.IOException; //导入方法依赖的package包/类
private void skip(int bytes){
try {
this.stream.read(new byte[bytes]);
} catch (IOException e) {
e.printStackTrace();
}
}
示例12: showHTML
import java.io.IOException; //导入方法依赖的package包/类
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);
}
示例13: onCreate
import java.io.IOException; //导入方法依赖的package包/类
@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);
}
示例14: parse
import java.io.IOException; //导入方法依赖的package包/类
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();
}
示例15: dumpLog
import java.io.IOException; //导入方法依赖的package包/类
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;
}