Java Code Examples for java.io.FileNotFoundException#printStackTrace()

The following examples show how to use java.io.FileNotFoundException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UploadFragment.java    From Learning-Resources with MIT License 6 votes vote down vote up
private void addImages(Uri uri) {
    try {
        boolean validateImages = imageHelper.isPictureValidForUpload(uri);
        CreateTempImagesFinishedEvent event = new CreateTempImagesFinishedEvent();
        List<Uri> uris = new ArrayList<>(1);
        uris.add(uri);

        CreateTempImagesTask createTempImagesTask = new CreateTempImagesTask(
                getActivity(), uris, event, validateImages, minImageWidth, minImageHeight);

        createTempImagesTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        dismissProgress();
    }
}
 
Example 2
Source File: TrainingAction.java    From ExamStack with GNU General Public License v2.0 6 votes vote down vote up
@RequestMapping(value = "/secure/upload-uploadify-file", method = RequestMethod.POST)
public @ResponseBody String uploadFile(HttpServletRequest request, HttpServletResponse response) {
	UserInfo userInfo = (UserInfo) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	List<String> filePathList = new ArrayList<String>();
	try {
		filePathList = FileUploadUtil.uploadFile(request, response, userInfo.getUsername());
	} catch (FileNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (Exception ex) {
		ex.printStackTrace();
	}

	if (filePathList.size() == 0) {
		return "系统错误";
	}

	return filePathList.get(0);
}
 
Example 3
Source File: LocalServer.java    From startup-os with Apache License 2.0 6 votes vote down vote up
@Inject
LocalServer(
    @Named("Server log path") String logPath,
    AuthService authService,
    CodeReviewService codeReviewService) {
  if (logToFile.get()) {
    // TODO: Figure out how to also direct Flogger to log file.
    try {
      PrintStream logStream = new PrintStream(logPath);
      System.setOut(logStream);
      System.setErr(logStream);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
  }
  server =
      ServerBuilder.forPort(localServerPort.get())
          .addService(authService)
          .addService(codeReviewService)
          .addService(ProtoReflectionService.newInstance())
          .build();
}
 
Example 4
Source File: DecompositionRDFWriter.java    From TableDisentangler with GNU General Public License v3.0 5 votes vote down vote up
public void printToFile(String filename)
{
	outputFileName = filename;
	 try {
			model.write(new FileOutputStream(outputFileName));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
}
 
Example 5
Source File: EosWallet.java    From EosCommander with MIT License 5 votes vote down vote up
public boolean loadFile( File jsonFile ){
    if ( ! jsonFile.exists() ) {
        return false;
    }

    try {
        return loadReader(new FileReader(jsonFile));
    }
    catch ( FileNotFoundException e) {
        e.printStackTrace();
        return false;
    }
}
 
Example 6
Source File: MappingFactory.java    From zelixkiller with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a map of class names to mapped classes given a Proguard mapping
 * file.
 * 
 * @param file
 * @return
 */
public static Map<String, MappedClass> mappingsFromProguard(File file, Map<String, ClassNode> nodes) {
	Map<String, MappedClass> base = mappingsFromNodes(nodes);
	MappingLoader loader = new ProguardLoader(nodes);
	try {
		Map<String, MappedClass> newMappings = loader.read(new FileReader(file));
		for (MappedClass mappedClass : newMappings.values()) {
			newMappings = linkMappings(mappedClass, newMappings);
		}
		base = fixFromMappingsText(base, newMappings);
	} catch (FileNotFoundException e) {
		e.printStackTrace();
	}
	return base;
}
 
Example 7
Source File: DocumentsContractApi21.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
public static Uri renameTo(Context context, Uri self, String displayName) {
    try {
        return DocumentsContract.renameDocument(context.getContentResolver(), self, displayName);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 8
Source File: ShowActivity.java    From ImageChoose with MIT License 5 votes vote down vote up
public static Bitmap getLoacalBitmap(String url) {
    try {
        FileInputStream fis = new FileInputStream(url);
        return BitmapFactory.decodeStream(fis);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 9
Source File: FormFile.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
/**
 * @param filname       文件名
 * @param file          上传的文件
 * @param parameterName 参数
 * @param contentType   内容内容类型
 */
public FormFile(String filname, File file, String parameterName, String contentType) {
    this.filname = filname;
    this.parameterName = parameterName;
    this.file = file;
    try {
        this.inStream = new FileInputStream(file);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    if (contentType != null) this.contentType = contentType;
}
 
Example 10
Source File: CTAKESClinicalPipelineFactory.java    From ctakes-clinical-pipeline with Apache License 2.0 5 votes vote down vote up
public static AnalysisEngineDescription getFastPipeline()
    throws ResourceInitializationException {
  AggregateBuilder builder = new AggregateBuilder();
  builder.add(getTokenProcessingPipeline());
  try {
    builder.add(AnalysisEngineFactory
        .createEngineDescription(
            DefaultJCasTermAnnotator.class,
            AbstractJCasTermAnnotator.PARAM_WINDOW_ANNOT_PRP,
            "org.apache.ctakes.typesystem.type.textspan.Sentence",
            JCasTermAnnotator.DICTIONARY_DESCRIPTOR_KEY,
            ExternalResourceFactory.createExternalResourceDescription(
                FileResourceImpl.class,
                FileLocator
                .locateFile("org/apache/ctakes/dictionary/lookup/fast/cTakesHsql.xml"))));
  } catch (FileNotFoundException e) {
    e.printStackTrace();
    throw new ResourceInitializationException(e);
  }
  builder.add(ClearNLPDependencyParserAE.createAnnotatorDescription());
  builder.add(PolarityCleartkAnalysisEngine.createAnnotatorDescription());
  builder.add(UncertaintyCleartkAnalysisEngine
      .createAnnotatorDescription());
  builder.add(HistoryCleartkAnalysisEngine.createAnnotatorDescription());
  builder.add(ConditionalCleartkAnalysisEngine
      .createAnnotatorDescription());
  builder.add(GenericCleartkAnalysisEngine.createAnnotatorDescription());
  builder.add(SubjectCleartkAnalysisEngine.createAnnotatorDescription());
  return builder.createAggregateDescription();
}
 
Example 11
Source File: Manifest.java    From APDE with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Save to the sketch folder, so that it can be copied in later.
 */
protected void save(File file) {
	try {
		PrintWriter writer = new PrintWriter(file);
		writer.print(xml.toString());
		writer.flush();
		writer.close();
	} catch (FileNotFoundException e) {
		e.printStackTrace();
	}
}
 
Example 12
Source File: ArtifactAsset.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public InputStream openStream() {
    try {
        return new FileInputStream(spec.file);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 13
Source File: InputFileProcessor.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
protected void resetReader() {
	try {
		this.inputFileReader = new BufferedReader(new FileReader(this.source));
	} catch (FileNotFoundException e) {
		System.out.println("The reader could not be reset.");
		e.printStackTrace();
	}
}
 
Example 14
Source File: RadialGlobalMenu.java    From RadialFx with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ImageView getImageView(final String path) {
ImageView imageView = null;
try {
    imageView = ImageViewBuilder.create()
	    .image(new Image(new FileInputStream(path))).build();
} catch (final FileNotFoundException e) {
    e.printStackTrace();
}
assert (imageView != null);
return imageView;

   }
 
Example 15
Source File: TestQueryBolt.java    From jstorm with Apache License 2.0 5 votes vote down vote up
public void prepare(Map stormConf, TopologyContext context,
    OutputCollector collector) {
  collector = this.collector;
  try {
    fos = new FileOutputStream(
        "src/test/resources/test-query.txt");
  } catch (FileNotFoundException e) {
    e.printStackTrace();
  }
}
 
Example 16
Source File: Config.java    From Minepacks with GNU General Public License v3.0 5 votes vote down vote up
public void setDatabaseType(String type)
{
	getConfigE().set("Database.Type", type);
	try
	{
		save();
	}
	catch(FileNotFoundException e)
	{
		e.printStackTrace();
	}
}
 
Example 17
Source File: RAFile.java    From jtransc with Apache License 2.0 5 votes vote down vote up
public RAFile(File file) {
	try {
		//this.file = new RandomAccessFile(new File(file.getAbsolutePath().replace("%20", " ")), "r");
		this.file = new RandomAccessFile(file, "r");
	} catch (FileNotFoundException e) {
		e.printStackTrace();
	}
}
 
Example 18
Source File: GlobalConfigurationTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testConfigurationYAML() {
	File tmpDir = tempFolder.getRoot();
	File confFile = new File(tmpDir, GlobalConfiguration.FLINK_CONF_FILENAME);

	try {
		try (final PrintWriter pw = new PrintWriter(confFile)) {

			pw.println("###########################"); // should be skipped
			pw.println("# Some : comments : to skip"); // should be skipped
			pw.println("###########################"); // should be skipped
			pw.println("mykey1: myvalue1"); // OK, simple correct case
			pw.println("mykey2       : myvalue2"); // OK, whitespace before colon is correct
			pw.println("mykey3:myvalue3"); // SKIP, missing white space after colon
			pw.println(" some nonsense without colon and whitespace separator"); // SKIP
			pw.println(" :  "); // SKIP
			pw.println("   "); // SKIP (silently)
			pw.println(" "); // SKIP (silently)
			pw.println("mykey4: myvalue4# some comments"); // OK, skip comments only
			pw.println("   mykey5    :    myvalue5    "); // OK, trim unnecessary whitespace
			pw.println("mykey6: my: value6"); // OK, only use first ': ' as separator
			pw.println("mykey7: "); // SKIP, no value provided
			pw.println(": myvalue8"); // SKIP, no key provided

			pw.println("mykey9: myvalue9"); // OK
			pw.println("mykey9: myvalue10"); // OK, overwrite last value

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}

		Configuration conf = GlobalConfiguration.loadConfiguration(tmpDir.getAbsolutePath());

		// all distinct keys from confFile1 + confFile2 key
		assertEquals(6, conf.keySet().size());

		// keys 1, 2, 4, 5, 6, 7, 8 should be OK and match the expected values
		assertEquals("myvalue1", conf.getString("mykey1", null));
		assertEquals("myvalue2", conf.getString("mykey2", null));
		assertEquals("null", conf.getString("mykey3", "null"));
		assertEquals("myvalue4", conf.getString("mykey4", null));
		assertEquals("myvalue5", conf.getString("mykey5", null));
		assertEquals("my: value6", conf.getString("mykey6", null));
		assertEquals("null", conf.getString("mykey7", "null"));
		assertEquals("null", conf.getString("mykey8", "null"));
		assertEquals("myvalue10", conf.getString("mykey9", null));
	} finally {
		confFile.delete();
		tmpDir.delete();
	}
}
 
Example 19
Source File: StatusMessageQueue.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
private StatusMessageType load(File file) {
   try {
      FileInputStream saveFile = new FileInputStream(file);
      ObjectInputStream save = new ObjectInputStream(saveFile);
      Object var4 = null;

      byte[] sealedObject;
      try {
         sealedObject = (byte[])save.readObject();
      } catch (IOException var7) {
         var7.printStackTrace();
         LOG.error("IOException: the file:" + file.getName() + "will be deleted\n" + var7.getMessage());
         save.close();
         saveFile.close();
         file.delete();
         return null;
      }

      save.close();
      saveFile.close();
      byte[] serializedObject = this.unseal(sealedObject);
      StatusMessageType result = (StatusMessageType)this.jaxContext.toObject(StatusMessageType.class, serializedObject);
      return result;
   } catch (FileNotFoundException var8) {
      var8.printStackTrace();
      return null;
   } catch (IOException var9) {
      var9.printStackTrace();
      LOG.error("IOException: the file:" + file.getName() + "will be deleted\n" + var9.getMessage());
      return null;
   } catch (ClassNotFoundException var10) {
      var10.printStackTrace();
      return null;
   } catch (IntegrationModuleException var11) {
      var11.printStackTrace();
      return null;
   } catch (GFDDPPException var12) {
      var12.printStackTrace();
      return null;
   }
}
 
Example 20
Source File: Eclat.java    From KEEL with GNU General Public License v3.0 4 votes vote down vote up
/**
  * It launches the algorithm
  */
 public void execute() {
     if (somethingWrong) { //We do not execute the program
         System.err.println("An error was found");
         System.err.println("Aborting the program");
         //We should not use the statement: System.exit(-1);
     } else {
     	this.proc = new EclatProcess(this.trans, this.minSupport, this.minConfidence);
     	this.proc.run();
     	this.associationRules = this.proc.generateRulesSet();
             	        	
try {
	int r, i;
	ArrayList<Integer> terms;
	AssociationRule a_r;
	
	double[] step_values = this.trans.getSteps();
	
	PrintWriter rules_writer = new PrintWriter(this.rulesFilename);
	PrintWriter values_writer = new PrintWriter(this.valuesFilename);
	PrintWriter valuesOrder_writer = new PrintWriter(this.valuesOrderFilename);
	
	rules_writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
	rules_writer.println("<rules>");
	
	values_writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
	values_writer.println("<values>");
	
	valuesOrder_writer.print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
	valuesOrder_writer.println("<values>");
	valuesOrder_writer.print("Support\tantecedent_support\tconsequent_support\tConfidence\tLift\tConv\tCF\tNetConf\tYulesQ\tnAttributes\n");
					
	for (r=0; r < this.associationRules.size(); r++) {
		a_r = this.associationRules.get(r);
		
		rules_writer.println("<rule id=\"" + r + "\">");
		values_writer.println("<rule id=\"" + r + "\" rule_support=\"" + EclatProcess.roundDouble(a_r.getRuleSupport(),2) + "\" antecedent_support=\"" + EclatProcess.roundDouble(a_r.getAntecedentSupport(),2) + "\" consequent_support=\"" +  EclatProcess.roundDouble(a_r.getConsequentSupport(),2) + "\" confidence=\"" + 
				 EclatProcess.roundDouble(a_r.getConfidence(),2) +"\" lift=\"" +  EclatProcess.roundDouble(a_r.getLift(),2) + "\" conviction=\"" +  EclatProcess.roundDouble(a_r.getConv(),2) + "\" certainFactor=\"" +  EclatProcess.roundDouble(a_r.getCF(),2) + "\" netConf=\"" +  EclatProcess.roundDouble(a_r.getNetConf(),2) + "\" yulesQ=\"" +  EclatProcess.roundDouble(a_r.getYulesQ(),2) + "\" nAttributes=\"" + (a_r.getAntecedent().size()+ a_r.getConsequent().size()) + "\"/>");
		
		rules_writer.println("<antecedents>");			
		terms = a_r.getAntecedent();
		
		for (i=0; i < terms.size(); i++)
			this.createRule(terms.get(i), step_values, rules_writer);
			
		rules_writer.println("</antecedents>");
		
		rules_writer.println("<consequents>");			
		terms = a_r.getConsequent();
		
		for (i=0; i < terms.size(); i++)
			this.createRule(terms.get(i), step_values, rules_writer);
		
		rules_writer.println("</consequents>");
		
		rules_writer.println("</rule>");
		
		valuesOrder_writer.print(printRule(a_r));
	}
	
	rules_writer.println("</rules>");
	values_writer.println("</values>");
	valuesOrder_writer.print("</values>");
	
	//this.proc.saveReport(this.associationRules, values_writer);
	
	rules_writer.close();
	values_writer.close();
	valuesOrder_writer.close();
	
	totalTime = System.currentTimeMillis() - startTime;
	this.writeTime();
	System.out.println("\nAlgorithm Finished");
}
catch (FileNotFoundException e) {
	e.printStackTrace();
}
     }
 }