Code example for File

Methods: createTempFile

0
		private String saveTmpFile(byte[] b, int offset, int len) {
			String path = "";
			if (len > 0) {
				String tmpdir = System.getProperty("java.io.tmpdir");
				try { 
					File temp = File.createTempFile("NanoHTTPD", "", new File(
							tmpdir));
					OutputStream fstream = new FileOutputStream(temp);
					fstream.write(b, offset, len);
					fstream.close();
					path = temp.getAbsolutePath();
				} catch (Exception e) { // Catch exception if any
					System.err.println("Error: " + e.getMessage());
				} 
			} 
			return path;
		} 
 
		/** 
		 * It returns the offset separating multipart file headers from the 
		 * file's data.