Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How can I read only text files in a directory.

2801625Apr 30 2015 — edited May 1 2015

I've written a program to read files in a directory but I'd like for it to only read the text files of that directory.

import java.io.*;

public class Data {

  public static void main(String[] args) throws IOException {

  String target_dir = "C:\\files";

  File dir = new File(target_dir);

  File[] files = dir.listFiles();

  for (File textfiles : files) {

  if (textfiles.isFile()) {

  BufferedReader inputStream = null;

  try {

  inputStream = new BufferedReader(new FileReader(textfiles));

  String line;

  while ((line = inputStream.readLine()) != null) {

  System.out.println(line);

  }

  } finally {

  if (inputStream != null) {

  inputStream.close();

  }

  }

  }

  }

  }

}

This post has been answered by aJohny on Apr 30 2015
Jump to Answer

Comments

ORASCN

May I know what kind of sessions are timed out?
Regards,
Veera

User51642 Yong Huang

I mean the web pages, e.g.:
h t t p : / / ouroggserver : 9100
h t t p : / / ouroggserver : 9101
(community.oracle.com tells me "You have to be around for a little while longer before you can post links" so I put spaces in the URLs)

ORASCN

That is expected. If you are not using the session for a longer time or the session is not active for a longer time, then surely it will get timed out. This is for the security reasons.
Regards,
Veera

User51642 Yong Huang

Anybody has an idea? I suspect not many people use MA so they don't use the web interface? This timeout setting doesn't seem to be documented anywhere.

Martin Maes

I have the same problem. Security people think that administrators use one screen at the time and don't leave it until they are done. In reality, we use different screens, get interrupted, go back again and find the screen or GUI locked. This happens several times a day and is not so helpful (although very secure :-) )

ORASCN

I kind of explored it, but couldn't find any options to set the timeout. It's default I believe as I already mentioned.
Regards,
Veera

User51642 Yong Huang

Thank you! In case you all have an idea about another annoying feature: Is there a way to prevent the login screen username and password pane from moving from the right of the screen to the left?

ORASCN

I have read the full message before it was edited
May be an SR can be opened and suggest the changes.

Regards,
Veera

1 - 8
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 29 2015
Added on Apr 30 2015
5 comments
1,037 views