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

x33g5p2x  于2022-01-18 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(147)

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

FileNotFoundException.printStackTrace介绍

暂无

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

@Override
  public InputStream openStream() {
    try{
      return new FileInputStream(selected);
    }catch (FileNotFoundException ex){
      ex.printStackTrace();
    }
    return null;
  }
});

代码示例来源:origin: CarGuo/GSYVideoPlayer

public static void saveBitmap(Bitmap bitmap, File file) {
  if (bitmap != null) {
    OutputStream outputStream;
    try {
      outputStream = new FileOutputStream(file);
      bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
      bitmap.recycle();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
  }
}

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

private static int readAPIVersion (File parentFile) {
  File propertiesFile = new File(parentFile, "source.properties");
  Properties properties;
  try {
    properties = readPropertiesFromFile(propertiesFile);
    String versionString = properties.getProperty("AndroidVersion.ApiLevel");
    return Integer.parseInt(versionString);
  } catch (FileNotFoundException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  } catch (NumberFormatException e) {
    e.printStackTrace();
  }
  return 0;
}

代码示例来源:origin: GitLqr/LQRWeChat

private static String saveBitmap(Bitmap bm, String imageUrlName) {
  File f = new File(SAVEADDRESS, imageUrlName);
  try {
    FileOutputStream out = new FileOutputStream(f);
    bm.compress(Bitmap.CompressFormat.JPEG, 100, out);
    out.flush();
    out.close();
  } catch (FileNotFoundException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return SCHEMA + f.getPath();
}

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

public static void printCounter(TwoDimensionalCounter<String,String> cnt,
                String fname) {
 try {
  PrintWriter pw = new PrintWriter(new PrintStream(new FileOutputStream(new File(fname)),false,"UTF-8"));
  for(String key : cnt.firstKeySet()) {
   for(String val : cnt.getCounter(key).keySet()) {
    pw.printf("%s\t%s\t%d%n", key, val, (int) cnt.getCount(key, val));
   }
  }
  pw.close();
 } catch (UnsupportedEncodingException e) {
  e.printStackTrace();
 } catch (FileNotFoundException e) {
  e.printStackTrace();
 }
}

代码示例来源:origin: redwarp/9-Patch-Resizer

@Override
protected Void doInBackground() throws Exception {
 FileOutputStream fos = null;
 try {
  fos = new FileOutputStream(DENSITIES_PATHNAME);
  PrintWriter writer = new PrintWriter(fos);
  writer.write(mSavePayload);
  writer.close();
 } catch (FileNotFoundException e) {
  e.printStackTrace();
  System.out.println("Couldn't save");
 }
 return null;
}

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

private void init(String file) {
  try {
    File f = new File(file);
    FileInputStream in = new FileInputStream(f);
    reader = new BufferedReader(new InputStreamReader(in,
        "UTF-8"));
  } catch (FileNotFoundException e) {			
    e.printStackTrace();
  } catch (UnsupportedEncodingException e) {
    e.printStackTrace();
  }
  line=0;
}

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

@ExpectWarning("RE,RV")
public static void main(String[] args) throws IOException {
  String name = "Mr. Ed";
  name = name.replaceAll(".", "s.");
  System.out.println(name);
  // FIXME:FindBugs only catches this error with name.indexOf(String)
  if (name.indexOf("s") > 0)
    System.out.println("Yay");
  else
    System.out.println("Boo");
  String result;
  try {
    BufferedReader findFiles = new BufferedReader(new FileReader("/mainList.txt"));
    if (findFiles.readLine() != null)
      result = findFiles.readLine();
    findFiles.close();
  } catch (FileNotFoundException e) {
    System.exit(7);
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  }
  LineNumberReader tmp = new LineNumberReader(new FileReader("/mainList.txt"));
  int count = 0;
  while (tmp.readLine() != null)
    count++;
  tmp.close();
}

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

/**
  */
 public static void main(String[] args) {
  LatticeXMLReader reader = new LatticeXMLReader();
  try {
   System.setIn(new FileInputStream(args[0]));
  } catch (FileNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }

  reader.load(System.in);

  int numLattices = 0;
  for(Lattice lattice : reader) {
   System.out.println(lattice.toString());
   numLattices++;
  }
  System.out.printf("\nLoaded %d lattices\n", numLattices);
 }
}

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

public static void outputModel(String fileName, Classifier<String, String> clf) {
 FileOutputStream fo = null;
 try {
  fo = new FileOutputStream(fileName);
  ObjectOutputStream so = new ObjectOutputStream(fo);
  so.writeObject(clf);
  so.flush();
  so.close();
 } catch (FileNotFoundException e) {
  e.printStackTrace();
 } catch (IOException e) {
  e.printStackTrace();
 }
}

代码示例来源:origin: sarxos/webcam-capture

private void caugh(Throwable t) {
  File f = new File(String.format("webcam-capture-hs-%s", System.currentTimeMillis()));
  PrintStream ps = null;
  try {
    t.printStackTrace(ps = new PrintStream(f));
  } catch (FileNotFoundException e) {
    e.printStackTrace();
  } finally {
    if (ps != null) {
      ps.close();
    }
  }
}

代码示例来源:origin: oracle/opengrok

private static PrintStream prepareOutput(File outFile) {
  PrintStream out = System.out;
  if (outFile != null) {
    try {
      out = new PrintStream(outFile, "utf-8");
    } catch (FileNotFoundException ex) {
      System.err.println("An error occurred - file does not exist");
      ex.printStackTrace(System.err);
      System.exit(3);
    } catch (UnsupportedEncodingException ex) {
      System.err.println("An error occurred - file contains unsupported charset");
      ex.printStackTrace(System.err);
      System.exit(3);
    }
  }
  return out;
}

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

private Set<String> loadMWEs() {
 Set<String> mweSet = Generics.newHashSet();  
 try {
  BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(mweFile), "UTF-8"));
  for (String line; (line = br.readLine()) != null;) {
   mweSet.add(line.trim());
  }
  br.close();
 
 } catch (UnsupportedEncodingException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 } catch (FileNotFoundException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 } catch (IOException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 }
 return mweSet;
}

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

public void setOffsetFromFile(RandomAccessFile f, ByteBuffer buf)
    throws IOException {
  long localHdrOffset = mLocalHdrOffset;
  try {
    f.seek(localHdrOffset);
    f.readFully(buf.array());
    if (buf.getInt(0) != kLFHSignature) {
      Log.w(LOG_TAG, "didn't find signature at start of lfh");
      throw new IOException();
    }
    int nameLen = buf.getShort(kLFHNameLen) & 0xFFFF;
    int extraLen = buf.getShort(kLFHExtraLen) & 0xFFFF;
    mOffset = localHdrOffset + kLFHLen + nameLen + extraLen;
  } catch (FileNotFoundException e) {
    e.printStackTrace();
  } catch (IOException ioe) {
    ioe.printStackTrace();
  }
}

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

public void test(String f) {
  try {
    FileInputStream in = new FileInputStream(f);
    int b = in.read();
    System.out.println(b);
  } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  } finally {
    if (bad.contains(f))
      System.out.println("oops");
  }
}

代码示例来源:origin: aa112901/remusic

public LogDumper(String pid, String dir) {
      mPID = pid;
      try {
        out = new FileOutputStream(new File(dir, "EDOG-" + MyDate.getFileName() + ".log"));
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      }

      /**
       *
       * 日志等级:*:v , *:d , *:w , *:e , *:f , *:s
       *
       * 显示当前mPID程序的 E和W等级的日志.
       *
       * */

      // cmds = "logcat *:e *:w | grep \"(" + mPID + ")\"";
      cmds = "logcat  | grep \"(" + mPID + ")\"";//打印所有日志信息
      // cmds = "logcat -s way";//打印标签过滤信息
//            cmds = "logcat *:v *:d *:w *:e *:f *:s *:i | grep \"(" + mPID + ")\"";

    }

代码示例来源:origin: mttkay/ignition

private void cacheToDisk(KeyT key, ValT value) {
  File file = new File(diskCacheDirectory + "/" + getFileNameForKey(key));
  try {
    file.createNewFile();
    file.deleteOnExit();
    writeValueToDisk(file, value);
  } catch (FileNotFoundException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  }
}

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

public final void setLogData(File logData) {
  this.logData = logData;
  logData.delete();
  PrintStream ps = null;
  try {
    ps = new PrintStream(new FileOutputStream(logData));
    ps.println();
  } catch (FileNotFoundException e) {
    Log.error("Cannot open " + logData);
    e.printStackTrace();
  } finally {
    if (ps != null) {
      ps.close();
    }
  }
}

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

public svmFileReader(String file) {
  try {
    File f = new File(file);
    FileInputStream in = new FileInputStream(f);
    reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
  } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  } catch (UnsupportedEncodingException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
}

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

public static void compareFiles(String filePath1, String filePath2, List<String> messageDeliverOrder) {
  System.out.println("Comparing " + filePath1 + " and " + filePath2 + " by thread " + Thread.currentThread().getName());
  try {
    BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath1));
        continue;
      } else if (realMsgIdx < msgExpectedIdx) {
        System.err.println("[" + Thread.currentThread().getName() + "] Message deliver out of order: " + message);
    e.printStackTrace();  // TODO: Customise this generated block
  } catch (IOException e) {
    e.printStackTrace();  // TODO: Customise this generated block
  } finally {
    System.out.println("Finished comparing this files");

相关文章