java.io.IOException.printStackTrace()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(198)

本文整理了Java中java.io.IOException.printStackTrace()方法的一些代码示例,展示了IOException.printStackTrace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOException.printStackTrace()方法的具体详情如下:
包路径:java.io.IOException
类名称:IOException
方法名:printStackTrace

IOException.printStackTrace介绍

暂无

代码示例

代码示例来源:origin: libgdx/libgdx

public void setImage (String file) {
  try {
    image = ImageIO.read( new File(file) );
  } catch (IOException e) {
    e.printStackTrace();
  } 
}

代码示例来源:origin: androidannotations/androidannotations

private static String[] getContents(File file) {
  List<String> content = new ArrayList<>();
  try (BufferedReader input = new BufferedReader(new FileReader(file))) {
    String line = null; // not declared within while loop
    while ((line = input.readLine()) != null) {
      content.add(line);
    }
  } catch (IOException ex) {
    ex.printStackTrace();
  }
  return content.toArray(new String[] {});
}

代码示例来源:origin: libgdx/libgdx

@Override
public void run () {
  BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
  String line = null;
  try {
    while ((line = reader.readLine()) != null) {
      // augment output with java file line references :D
      printFileLineNumber(line);
    }
  } catch (IOException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: stanfordnlp/CoreNLP

private static void resolveDummyTags(File treeFile,
  TwoDimensionalCounter<String, String> pretermLabel,
  TwoDimensionalCounter<String, String> unigramTagger) {
 try {
  BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(treeFile), "UTF-8"));
  TreeReaderFactory trf = new FrenchTreeReaderFactory();
  TreeReader tr = trf.newTreeReader(br);
  PrintWriter pw = new PrintWriter(new PrintStream(new FileOutputStream(new File(treeFile + ".fixed")),false,"UTF-8"));
  int nTrees = 0;
  for(Tree t; (t = tr.readTree()) != null;nTrees++) {
   traverseAndFix(t, pretermLabel, unigramTagger);
   pw.println(t.toString());
  }
  pw.close();
  tr.close();
  System.out.println("Processed " +nTrees+ " trees");
 } catch (UnsupportedEncodingException e) {
  e.printStackTrace();
 } catch (FileNotFoundException e) {
  e.printStackTrace();
 } catch (IOException e) {
  e.printStackTrace();
 }
}

代码示例来源:origin: lingochamp/FileDownloader

private InputStream initPerformanceTest() {
  try {
    final File file = new File(writePerformanceTestPath);
    if (file.exists()) {
      file.delete();
    }
    file.createNewFile();
    return getResources().getAssets().open("performance_test_data");
  } catch (IOException e) {
    e.printStackTrace();
  }
  return null;
}

代码示例来源:origin: marytts/marytts

private static void saveIndex() {
  assert remote2local != null;
  File downloadDir = new File(System.getProperty("mary.downloadDir", "."));
  File licenseIndexFile = new File(downloadDir, "license-index.txt");
  try (PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(licenseIndexFile), "UTF-8"))) {
    for (URL remote : remote2local.keySet()) {
      pw.println(remote2local.get(remote) + "|" + remote.toString());
    }
  } catch (IOException e) {
    System.err.println("Problem updating the index file " + licenseIndexFile.getAbsolutePath());
    e.printStackTrace();
  }
}

代码示例来源:origin: shuzheng/zheng

File dir = new File(outputPath);
if (!dir.exists()) {
  dir.mkdirs();
    JarEntry je = e.nextElement();
    String outFileName = outputPath + je.getName();
    File f = new File(outFileName);
    if (je.isDirectory()) {
      if (!f.exists()) {
        f.mkdirs();
      if (!pf.exists()) {
        pf.mkdirs();
  System.out.println("解压" + fileName + "出错!" + e.getMessage());
} finally {
  if (jf != null) {
      jf.close();
    } catch (IOException e) {
      e.printStackTrace();

代码示例来源:origin: voldemort/voldemort

private static Versioned<Properties> doMetaGetVersionsForNode_ExitOnError(AdminClient adminClient,
                                Integer nodeId) {
  try {
    return doMetaGetVersionsForNode(adminClient, nodeId);
  } catch(IOException e) {
    System.err.println("Error while retrieving Metadata versions from node : " + nodeId
              + ". Exception = " + e.getMessage() + " \n");
    e.printStackTrace();
    System.exit(-1);
    return null;
  }
}

代码示例来源:origin: neo4j/neo4j

private static void printLog( String description, File file, PrintStream out )
{
  if ( file != null && file.exists() )
  {
    out.println( String.format( "---------- BEGIN %s ----------", description ) );
    try ( BufferedReader reader = new BufferedReader( new FileReader( file ) ) )
    {
      reader.lines().forEach( out::println );
    }
    catch ( IOException ex )
    {
      out.println( "Unable to collect log files: " + ex.getMessage() );
      ex.printStackTrace( out );
    }
    finally
    {
      out.println( String.format( "---------- END %s ----------", description ) );
    }
  }
}

代码示例来源:origin: FudanNLP/fnlp

public boolean hasNext() {
  try {
    content = reader.readLine();
    if (content == null) {
      reader.close();
      return false;
    }
  } catch (IOException e) {
    e.printStackTrace();
    return false;
  }
  return true;
}

代码示例来源:origin: stanfordnlp/CoreNLP

private void setNext() {
 String line = null;
 try {
  line = in.readLine();
 } catch (IOException ioe) {
  ioe.printStackTrace();
 }
 if (line != null) {
  nextToken = op.apply(line);
 } else {
  nextToken = null;
 }
}

代码示例来源:origin: libgdx/libgdx

@Override
public void run () {
  BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
  String line = null;
  try {
    while ((line = reader.readLine()) != null) {
      // augment output with java file line references :D
      printFileLineNumber(line);
    }
  } catch (IOException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: stanfordnlp/CoreNLP

/**
 * @param args
 */
public static void main(String[] args) {
 if(args.length != 1) {
  System.err.printf("Usage: java %s tree_file > trees%n", HebrewTreeReaderFactory.class.getName());
  System.exit(-1);
 }
 TreebankLanguagePack tlp = new HebrewTreebankLanguagePack();
 File treeFile = new File(args[0]);
 try {
  TreeReaderFactory trf = new HebrewTreeReaderFactory();
  BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(treeFile), tlp.getEncoding()));
  TreeReader tr = trf.newTreeReader(br);
  int numTrees = 0;
  for(Tree t; ((t = tr.readTree()) != null); numTrees++)
   System.out.println(t.toString());
  tr.close();
  System.err.printf("Processed %d trees.%n",numTrees);
 } catch (UnsupportedEncodingException e) {
  e.printStackTrace();
 } catch (FileNotFoundException e) {
  e.printStackTrace();
 } catch (IOException e) {
  e.printStackTrace();
 }
}

代码示例来源:origin: jeasonlzy/ImagePicker

/** 根据系统时间、前缀、后缀产生一个文件 */
private File createFile(File folder, String prefix, String suffix) {
  if (!folder.exists() || !folder.isDirectory()) folder.mkdirs();
  try {
    File nomedia = new File(folder, ".nomedia");  //在当前文件夹底下创建一个 .nomedia 文件
    if (!nomedia.exists()) nomedia.createNewFile();
  } catch (IOException e) {
    e.printStackTrace();
  }
  SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA);
  String filename = prefix + dateFormat.format(new Date(System.currentTimeMillis())) + suffix;
  return new File(folder, filename);
}

代码示例来源:origin: marytts/marytts

private static void saveIndex() {
  assert remote2local != null;
  File downloadDir = new File(System.getProperty("mary.downloadDir", "."));
  File licenseIndexFile = new File(downloadDir, "license-index.txt");
  try (PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(licenseIndexFile), "UTF-8"))) {
    for (URL remote : remote2local.keySet()) {
      pw.println(remote2local.get(remote) + "|" + remote.toString());
    }
  } catch (IOException e) {
    System.err.println("Problem updating the index file " + licenseIndexFile.getAbsolutePath());
    e.printStackTrace();
  }
}

代码示例来源:origin: objectbox/objectbox-java

URL resource = NativeLibraryLoader.class.getResource(path);
if (resource == null) {
  System.err.println("Not available in classpath: " + path);
} else {
  File file = new File(filename);
  try {
    URLConnection urlConnection = resource.openConnection();
    int length = urlConnection.getContentLength();
    long lastModified = urlConnection.getLastModified();
    if (!file.exists() || file.length() != length || file.lastModified() != lastModified) {
      InputStream in = new BufferedInputStream(urlConnection.getInputStream());
      try {
    e.printStackTrace();

代码示例来源:origin: libgdx/libgdx

public void setImage (String file) {
  try {
    image = ImageIO.read( new File(file) );
  } catch (IOException e) {
    e.printStackTrace();
  } 
}

代码示例来源:origin: voldemort/voldemort

public void run() {
  try {
    internalRun();
  } catch(IOException e) {
    System.out.println("Store processing interrupted " + store
              + " because of IOException " + e.getMessage());
    e.printStackTrace();
  }
}

代码示例来源:origin: baomidou/mybatis-plus

protected static String readFile(String path, String fileName) {
  StringBuilder builder = new StringBuilder();
  try (
    BufferedReader reader = new BufferedReader(new FileReader(filePath(path, fileName)))
  ) {
    String line;
    while ((line = reader.readLine()) != null)
      builder.append(line).append(" ");
  } catch (IOException e) {
    e.printStackTrace();
  }
  return builder.toString();
}

代码示例来源:origin: apache/storm

@Override
public void nextTuple() {
  try {
    String line = null;
    while ((line = br.readLine()) != null) {
      collector.emit(Arrays.asList(line.split(",")));
    }
  } catch (IOException e) {
    closeReader();
    e.printStackTrace();
  }
}

相关文章