Skip to content
Advertisement

Tag: file-io

Java: reading objects from file into different derived classes

I have class Employee, and two derived classes Hourly and Salary. Instantiations of those derived classes are placed in the same Array List called employeeList. When I read these objects from file using ois.readObject() how can I ensure the data ends up in the appropriate derived class? Thank you! Answer Note: I am not familiar with ObjectInputStream, so I am

Java .split method returning empty array

I am trying to count all the words in each sentence in an array of multiple sentences automatically from a file in eclipse. When I’m splitting the paragraph into sentences the java .split method is returning an empty array Here is the code that is causing me trouble here is my sentence class And finally, here is my text file

Writing multiple lines using PrintWriter in Java

I am sorry if this question is already answered on the internet but by looking at the ‘similar questions’ I couldn’t find an answer for my problem. So basically I’m trying to understand why using PrintWriter to write lines of text into a file apparently skips the first line every 2 lines I give. This is the method I use

Several Errors being Logged for File I/O code

Here is my code from learning the File i/o… Whenever I try to open the ABC1.txt file from the workspace folder (In C:), it shows the size of 12.00 MB and whenever I refresh the folder the size also gets increased each time . And another thing I want to mention is, I m not able to see the File

Advertisement