Creates a click event that opens a file.

<p>This action is not readable, and may only be used locally on the client.</p>

@param file the file to open
@return a click event
18086
public static @NonNull ClickEvent openFile(final @NonNull String file) {
    return new ClickEvent(Action.OPEN_FILE, file);
  }
835758
private void fromFileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fromFileButtonActionPerformed
        // Allow user to select a file, and read input data from that file
        JFileChooser fileChooser = new JFileChooser();
        if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
            File file = fileChooser.getSelectedFile();
            try {
                dataInputArea.setText(OpenFile.ReadFile(file, false));
            } catch (Exception e) {
                System.out.println("Cannot read from file" + fileChooser.getSelectedFile().toString());
            }
        }
    }
911626
public static Exception checkFile(final File file)
	{
		Exception ex = null;
		String error = null;
		// check if the file does not exists...
		if (!file.exists())
		{
			error = "The " + file + " does not exists.";
			ex = new FileDoesNotExistException(error);
			return ex;
		}
		// check if the file is not a directory...
		if (!file.isDirectory())
		{
			error = "The " + file + " is not a directory.";
			ex = new FileIsNotADirectoryException(error);
			return ex;
		}

		final File[] ff = file.listFiles();
		// If the file is null
		if (ff == null)
		{ // it is security restricted
			error = "The " + file + " could not list the content.";
			ex = new DirectoryHasNoContentException(error);
		}
		return ex;
	}
992065
public void openFile(File file) {
		final String path = massageFilePath(file);
		if( path == null )
			return;
		inputFilePath = path;

		// update recent items menu
		BoofSwingUtil.invokeNowOrLater(() -> {
			BoofSwingUtil.addToRecentFiles(DemonstrationBase.this,path);
			updateRecentItems();
		});

		BufferedImage buffered = inputFilePath.endsWith("mjpeg") ? null : UtilImageIO.loadImage(inputFilePath);
		if( buffered == null ) {
			if( allowVideos )
				openVideo(false,inputFilePath);
		} else if( allowImages ){
			openImage(false,file.getName(), buffered);
		}
	}
748863
public static File exists(File file) {
		Validate.notNull(file);
		if(!file.exists())
			throw new ParameterException("\""+file+"\" does not exist!");
		return file;
	}
1318945
public void addFile(File file) {
        if (file != null && file.exists()) {
            try {
                classPath.add(file.toURI().toURL());
            } catch (MalformedURLException e) {
                throw new AssertionError("converting an existing file to an url should have never thrown an exception!");
            }
        }
    }
6937
public static FileValue fileValue(File file){
    String contentType = MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(file);
    return new FileValueBuilderImpl(file.getName()).file(file).mimeType(contentType).create();
  }
398566
public static JarFile create(String file) {
        try {
            return new JarFile(file);
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }
403809
public static boolean create(File file) {

		boolean created = false;

		// Validate or add the file extension
		if (GeoPackageIOUtils.hasFileExtension(file)) {
			GeoPackageValidate.validateGeoPackageExtension(file);
		} else {
			file = GeoPackageIOUtils.addFileExtension(file,
					GeoPackageConstants.GEOPACKAGE_EXTENSION);
		}

		if (file.exists()) {
			throw new GeoPackageException("GeoPackage already exists: "
					+ file.getAbsolutePath());
		} else {
			// Create the GeoPackage Connection
			GeoPackageConnection connection = connect(file);

			// Set the GeoPackage application id and user version
			connection.setApplicationId();
			connection.setUserVersion();

			// Create the minimum required tables
			GeoPackageTableCreator tableCreator = new GeoPackageTableCreator(
					connection);
			tableCreator.createRequired();

			connection.close();
			created = true;
		}

		return created;
	}
516122
public static WatchMonitor create(File file, WatchEvent.Kind<?>... events){
		return create(file, 0, events);
	}
1301045
public static File createTempFile(File file) {
        String[] prefixSuffix = getPrefixSuffix(file);
        try {
            File tempFile =
                    File.createTempFile(prefixSuffix[0], prefixSuffix[1]);
            tempFile.deleteOnExit();
            return tempFile;
        } catch (Exception e) {
            return JMExceptionManager.handleExceptionAndReturnNull(log, e,
                    "createTempFile", file);
        }
    }
121407
public BufferedImage createImage(File file) throws IOException {
		resetAvailabilityFlags();
		this.data = PELoader.loadPE(file);
		image = new BufferedImage(fileWidth, height, IMAGE_TYPE);

		drawSections();

		Overlay overlay = new Overlay(data);
		if (overlay.exists()) {
			long overlayOffset = overlay.getOffset();
			drawPixels(colorMap.get(OVERLAY), overlayOffset,
					withMinLength(overlay.getSize()));
			overlayAvailable = true;
		}

		drawPEHeaders();
		drawSpecials();
		drawResourceTypes();
		assert image != null;
		assert image.getWidth() == fileWidth;
		assert image.getHeight() == height;
		return image;
	}
713421
public static @Nullable FileBinaryResource createOrNull(File file) {
    return (file != null) ? new FileBinaryResource(file) : null;
  }
1074599
public static String fromFile(File file) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader(file));
        StringBuilder sb = new StringBuilder();
        String line = br.readLine();

        while (line != null) {
            sb.append(line);
            line = br.readLine();
            if (line != null)
                sb.append(System.lineSeparator());
        }

        br.close();
        return sb.toString();
    }
1318251
public static FileCreationState newFile(final File file) throws IOException
	{
		FileCreationState fileCreationState = FileCreationState.ALREADY_EXISTS;
		if (!file.exists())
		{
			fileCreationState = FileCreationState.FAILED;
			newParentDirectories(file);
			if (file.createNewFile())
			{
				fileCreationState = FileCreationState.CREATED;
			}
		}
		return fileCreationState;
	}
654322
protected void createNewFile(final File file) {
        try {
            file.createNewFile();
            setFileNotWorldReadablePermissions(file);
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }
701158
public void setFile(String file) {

        if (file != null) {
            m_file = file.toLowerCase();
        } else {
            m_file = null;
        }
    }