File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes hide opened file using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "hide opened file using java" Watch "hide opened file using java" New topic

hide opened file using java

monicka rk akilan

Joined: Jan 04, 2013
Posts: 8

Am new to this site..
I need to hide lastly opened file using java..
Winston Gutkowski

Joined: Mar 17, 2011
Posts: 8927

monicka rk akilan wrote:I need to hide lastly opened file using java.

Welcome to JavaRanch, Monicka.

A few things for you:
1. EaseUp (←click) - We're all volunteers here, and urgency is your problem, not ours.
2. TellTheDetails (←click) - Right now, I have no idea what you mean by 'hide lastly opened file'.

My suggestion: explain, in English, and in detail, what you're trying to do, and where this 'hiding' business comes in.

A few pages that might help you to ask your question a bit better:
How to provide an SSCCE
How to ask questions the smart way


Bats fly at night, 'cause they aren't we. And if we tried, we'd hit a tree -- Ogden Nash (or should've been).
Articles by Winston can be found here
monicka rk akilan

Joined: Jan 04, 2013
Posts: 8
hi winston

i need to print a text file using Desktop class.
when i use that that file is first opening and then print..
but i no need to make that file visible to user.
how to hide that file..
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11952

Are you asking how to make the operating system not see a file if it has been opened in Java?

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15081

Monicka, welcome to the Ranch.

Remember that we don't know anything at all about your program. That means you have to explain in detail what your program does, what it looks like, and what exactly you want to change. For example, we have no idea where and how the "opened file" is displayed or even what exactly you mean by that. Is your application a web application, or a desktop application? Does the opened file appear in a "recently used files" menu and you want to hide it from there? Or is your question about something entirely different?

We can't give you any useful answers unless you explain in detail what you mean.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Tony Docherty

Joined: Aug 07, 2007
Posts: 2830
I think this is beyond the control of your application when launching the print via the Desktop class. I believe the Desktop class just executes the Print command for the application associated with this file type. What happens next is up to the application.

Some applications such as Word have command line switches that allow you to control their behaviour but you would then need to launch the application via Process so you would need to know the correct application to use for your file, the path to the application and what switches to add.
monicka rk akilan

Joined: Jan 04, 2013
Posts: 8
Hai every one... thanks for your suggestion...
this is my code....
when i run this code the file is showing first and then printing...
i dont want to show the file....
Without showing the file. i want to print directly....
thanks in advance.

How to make this with out show file....

-Monicka Akilan
Tony Docherty

Joined: Aug 07, 2007
Posts: 2830
Please UseCodeTags (← click) when posting code as it makes it easier for people to read your code. I've added them for you this time.

What application is opening to print the file, and is it closing after printing?

As I said in my previous post you can't control the visibility of the application. If your application isn't closing after it has printed and you are on a Windows machine you can print text files using Notepad by using java.lang.Process (created from java.lang.ProcessBuilder) ie:
This will open Notepad displaying the file, print it and then close notepad.
I agree. Here's the link:
subject: hide opened file using java
It's not a secret anymore!