The java.io package provides blocking input and output through data streams, serialization, and the file system.
4
votes
5answers
14k views
hadoop java.io.IOException: while running namenode -format
I ran namenode -format.This is my output. I tried changing the file permissions chmod 777 hadoop.
I believe this line is the error
ERROR namenode.NameNode: java.io.IOException: Cannot create ...
0
votes
1answer
23 views
How to use information from a document to calculate total pay with java program
I made a program that reads text files and a program that calculates total pay including overtime. How can the two be combined to make a program that takes the employee's info from a text file to ...
1
vote
0answers
24 views
How to simulate a console input from outside a java file
I need to compile and run a java class from inside another java class, then input something into the console of the former.
The (console) output of the tested class needs to be redirected to the ...
1
vote
2answers
28 views
Weka java.io.IOException Error while loading Arff file
I get error while loading Arff file, and when i load the csv file and click "visualize all", nothing can be visualized and the screen gives "Too many values to display". Here is the error while ...
0
votes
3answers
29 views
Retrieve specific string from txt file in java
Hey I have a txt file I wanna read only a specific string from it.
The File:
This Ticket Being Generated as You Confirm
Name : John
Movie : Batman
Location: MidVally
Time : 7PM-9PM
Time ...
-2
votes
1answer
25 views
java howto load and save a ArrayList object
I've pair the code down to the methods I am having a problem, with. It 'seems' to work until I try to load the file again, and it comes up with nothing in it. (I have not fully understood how to ...
0
votes
0answers
33 views
Java reader does not start printing until closing the programm [duplicate]
Loop doesn t start printing until i m closing the program.I tried everything to bring it working but nothing helps.
The Shell script is running a python Script which prints in line format.
This (Java ...
0
votes
1answer
29 views
Storm reading files throws “Java.lang.OutOfMemoryError: GC overhead limit exceeded”
I've been working on a Storm topology, I read from a file in the "Execute(tuple)" method and java throws me a "Java.lang.OutOfMemoryError: GC overhead limit exceeded".
The program works fine until it ...
0
votes
2answers
32 views
How to do multiple clients with 1 server? Can u help me?
This is my server. Im using JFrame by the way. Actually i have many pc's when i run the server in pc 1 then the client that is on the pc 2 and pc 3. The pc 3 client connect but the server cannot ...
0
votes
0answers
19 views
Java: Unable to read file using FileReader [duplicate]
import java.io.*;
import java.util.Scanner;
public class Airline {
private static final int MAX_COLUMNS = 6;
private static final int MAX_ROWS = 30;
public String[][] seatArray ...
1
vote
1answer
150 views
Named pipe is connected while checking if it exists from Java
I am using Lukas Thomsen's named pipe example to create a pipe server in C++ and a reader in Java.
On the Java side I want to wait until the Named Pipe is created by C++ server.
File file = new File(...
2
votes
1answer
30 views
How can I loop a sound without using 'clip' in java before writing it into a file
First of all thanks everyone for helping me with my previous questions.
In the following code I am taking two frequencies alternatively and writing them into a .wav format, to run it in my Windows ...
-2
votes
2answers
29 views
How to Handle Unable to Open the File in Android using External Application
File file = new File(s);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
...
0
votes
3answers
16 views
Difference in reading file when using a string variable [duplicate]
I have written below code for reading a file:
package com.test.application;
import java.io.*;
import java.io.IOException;
public class FileRead {
public static void main(String[] args) {
...
-3
votes
1answer
16 views
java IO I CREATE A TXT. FILE BUT I CANNOT FIND WHERE IT SAVE
import java.io.*;
public class FileReaderDemo
{
public static void main(String args[])throws Exception
{
File f = new File ("wayback.txt");
f.createNewFile();
System.out.println(f.exists());
}
...
0
votes
0answers
35 views
the Permission (java.io.FilePermission <<ALL FILES>> execute) has not been granted to User
I have a Java class that executes a JAR file on db server, I loaded the Java class using loadjava command and created a function in PLSQL to execute the Java class.
This JAR file creates some files ...
0
votes
0answers
18 views
Different sockets
Is there anyway that you can use 2 different sockets that connect to the same IP and port and have them do different jobs e.g this socket used for chatting, the other is used for sending file.
0
votes
1answer
26 views
Data Stream in Java
I am using Data Stream class in java to perform read and write operations. My question is I am not closing both the streams and not even flushing the data then how it is working properly.
I mean to ...
18
votes
3answers
48k views
How to find sub-directories in a directory/folder?
I'm looking for a way to get all the names of directories in a given directory, but not files.
For example, let's say I have a folder called Parent, and inside that I have 3 folders: Child1 Child2 ...
9
votes
5answers
54k views
Checking if a number entered is odd
`I'm not sure what code to insert or even where, but I would like to check the number I enter is an odd number.
import java.io.*;
import javax.swing.JOptionPane;
public class Diamond {
public ...
-1
votes
0answers
24 views
play Histogram of image selected by user [duplicate]
i have 3 class
1- main class
2- histogram class,
and LoadImage class
So I arrived to display the image in Jscrollpane but the problem is that I can retrieve the image for use in the Histogaram ...
1
vote
1answer
29 views
Java reading decrypted file - file not found exception [duplicate]
I am trying to read decrypted property file.
File location is /WEB-INF/classes/db.properties
Decoder java file is src/a2.util/Decoder.java
which has method called readFile(String fileName).
When I ...
-1
votes
2answers
34 views
How to strip the first few characters of an input stream in java?
I have a fileInputStream object that may or may not contain xml declaration <?xml version='1.0'?>. I need to strip the xml declaration if it exists. How do I do that without converting the ...
0
votes
0answers
18 views
Java: Pull WAV file from a URL and save it to drive
I've been working on a game for fun and I want to pull sound files (.wav) from a url and download it. I've tried a couple of different codes that other people have used, but I usually get a "Server ...
14
votes
4answers
6k views
how to create a file with world readable permission under subdirectory of files directory
I need to create files under myapp/files/subdir with global permission in my application. I do this because I use external applications to open some files
Using this
FileOutputStream fos = ...
1
vote
3answers
37 views
What is the recommended way close IO resources declared as instance variables
In some of the Java classes I see the IO resources declared as instance varibles and are being used in multiple methods.How can I close them?Few Suggested finalize() and they also say that it is not ...
1
vote
0answers
15 views
How to Explicitly terminate OkHttpDownloader instance
I'm using Picasso, so I tried to manage catching using OkHTTP, after setting strick mode, I'm now getting "A resource was acquired at attached stack trace but never released" error.
Here's what's in ...
0
votes
3answers
61 views
BufferedWriter: Write to file before it is closed
So in my program I have a BufferedWriter that is used to create log files of what the program is doing.
private BufferedWriter logWriter;
logWriter = new BufferedWriter(new FileWriter(logFile));
In ...
-1
votes
1answer
36 views
Read Data From File Using Command Line Java [duplicate]
As I am new here and I have search some questions but not able to full fill my requirement, so please help me for this.
How can I allow user to enter the path of file as command line argument and ...
1
vote
2answers
273 views
Android Wear: save file locally
it is possible to saving file in a wearable?
i try the same procedure i use on phone but java.io send me an Exception.
File directory = null;
File sd = Environment....
0
votes
2answers
30 views
Speeding up reading from InputStream and writing with FileOutputStream
I'm reading some blob's from a column of a databse and them saving to a file using FileOutputStream.
This is my code:
InputStream binaryFile = rs_ivol.getBinaryStream("BLOB_COLUMN_FROM_BY_DB");
...
2
votes
2answers
7k views
Zip file created on server and download that zip, using java
I have the below code got from mkyong, to zip files on local. But, my requirement is to zip files on server and need to download that. Could any one help.
code wrote to zipFiles:
public void ...
3
votes
1answer
81 views
Reading file containing random numbers, sorting it and than writing to other file
In an interview I was asked the following question,
There is a file named sourceFile.txt containing random numbers aligned one below other like below,
608492
213420
23305
255572
64167
144737
81122
...
0
votes
1answer
31 views
I want to create a text file with name coming from user and the write in it?
I wrote this program for my uni Assignment. The main idea is when ever the addItem is invoked it creates a text file and write order from the user on that file. But how ever it only creates the file ...
1
vote
1answer
46 views
Sometimes FileNotFoundException at Url
Sorry for bad English.
My problem is so similar this issue "FileNotFoundException at URL"
but sometimes it gives error and doesnt continue but sometimes it works perfectly. This problem is in first ...
-1
votes
2answers
31 views
Java - How to Open the Last Updated File From a Folder that is Sorted by last modified date?
I am trying to open a csv file from the download directory in Windows. Here is the algorithm:
Go to the download directory in Window
Sort directory based on the last modify date with last updated ...
0
votes
0answers
16 views
ImageIO.read(InputStream) returns null with byte array input [duplicate]
The input is a plain text file that contains bytes of a TIF file. The goal is to output it as an image, but when I try to read the byte stream, it will just return null. Here's my code.
public ...
0
votes
1answer
19 views
User input file/directory
I am trying to create a program able to copy a file from one directory to another, but I need to ask the user to select the file, and input the directory. How do i do that?
This is what I have done ...
-1
votes
2answers
665 views
Which capability exists only in java.io.FileWriter?
Which capability exists only in java.io.FileWriter?
A. Closing an open stream.
B. Flushing an open stream.
C. Writing to an open stream.
D. Writing a line separator to an open stream.
I know ...
19
votes
5answers
38k views
How to get file content in java?
to get the content of a txt file I usually use a scanner and iterate over each line to get the content:
Scanner sc = new Scanner(new File("file.txt"));
while(sc.hasNextLine()){
String str = sc....
-2
votes
1answer
25 views
Does PrinterWriter creates a file if it doesn't exists?
I am using PrintWriter object file as below:
PrintWriter pwriter = new PrintWriter("abc.txt");
Please let me know if a file name abc.txt will be created if it doesn't exist.
I have tried it and it ...
0
votes
0answers
25 views
Jenkins giving JAVA.io.IOException while installing plugins
I have installed latest version of Jenkins (2.19.1) on my server as windows service, when I am trying to install Plugins like SVN, MSBuild etc it is giving me error Java.io.IOException. Any idea what ...
0
votes
0answers
21 views
Get Directory Access Rights for a operating system user running java process
I am trying to find if the user running the java process on a machine has permissions to access a particular filesystem directory.
I tried the following:
import java.nio.file.*;
import java.nio.file....
1
vote
3answers
69 views
Effective way to read file and parse each line
I have a text file of next format: each line starts with a string which is followed by sequence of numbers. Each line has unknown length (unknown amount of numbers, amount from 0 to 1000).
string_1 3 ...
96
votes
9answers
78k views
java.io.Console support in Eclipse IDE
I use the Eclipse IDE to develop, compile, and run my Java projects. Today, I'm trying to use the java.io.Console class to manage output and, more importantly, user input.
The problem is that System....
1
vote
3answers
2k views
0
votes
2answers
45 views
The Properties.load would close the InputStream?
I saw this example, and I didn't see the close() method invoked on the InputStream, so would prop.load() close the stream automatically? Or is there a bug in the example?
0
votes
3answers
987 views
Reading password from Console in java
I want to read password from console in one my java program. I used
Console newConsole = System.console();
But I could able to declare and initialize console object in my class.
I am getting an ...
0
votes
2answers
40 views
Java I/O stream
I am trying to copy the content of one file to another using Java I/O Stream.
I have written below code for this, but it is copying only the last letter of the source file.
package io.file;
...
79
votes
13answers
80k views
How do I list the files inside a JAR file?
I have this code which reads all the files from a directory.
File textFolder = new File("text_directory");
File [] texFiles = textFolder.listFiles( new FileFilter() {
public ...