How To Store File Properties In A File For Notepad
Dec 4, 2014
I'm not too familiar with serialization.It actually I found at this site (Java - Serialization) says that it will write and read properties of an object. I'm not quite sure how this would work as I would have thought that writing it to a text file would just do a toString() when you wrote it, but the page seems to think otherwise, and also names it .ser or something instead of .txt.
I thought, maybe this would work with my idea for a notepad that could store a Font, font color, and other settings, for the file. It would be beyond normal notepads. However, could you do this for a file as it would store text plus other things.
The upshot of this is that the same file, I was hoping to be able to be read by regular text programs like Notepad. However, could Notepad read such a modified file? Also, if notepad wrote to it, would it destroy my font properties and stuff that I'd add to it?
Also, what does this mean:
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans package. Please see XMLEncoder.
Originally, I was going to use FileAttribute or something like that but it looked hard to do and likely not what I wanted. However, this looks more like what I want, but I'd like to know. This could be a huge breakthrough for a lot of things I was hoping to do but never could think of an efficient way to do.
Update:This serializable thing works great for my text editor but it won't work too hot if another program like Notepad reads it as it will appear like gibberish, including the text.
I had thought of having it make two files, one regular, and one that was serialized, to deal with this, but this doesn't work if I try opening a file that another text editor created that might not have this other serialized version of the file.
Also, I haven't yet tried extending File itself yet. However, I still don't see how it would work the way I'd hoped.
In a way, I want it to be like a RTF with some things used to set te font of the text area when loaded but be able to deal with opening a file made by another text editor and also have another text editor be able to read it even if my text editor created it.
View Replies
ADVERTISEMENT
Mar 9, 2015
I am new to java and I am creating a system that will ask the user to create a file that will store to a text file, Once the user created the file I have a class that will let the user input the subject name that has been created, However, I keep on getting this java.util.nosuchelementexception.Here's my code:
public void display_by_name()
{
String id, name,total;
String key[]=new String[30];
String value[]=new String[30];
int i=0;
[code]....
View Replies
View Related
Apr 14, 2015
when open file "rahul.txt"so it shows characters which i stored not byte code i want to stored in file byte code. Now i have a problem for file handling it is not store bytes into myfile. it stores character not bytes.
package com.fileh;
import java .io.*
public class Writedata {
public static void main(String args[])
{
try{
FileOutputStream fout= new FileOutputStream("rahul.txt");
String s="my name is rahul";
byte[] b =s.getBytes();
fout.write(b);
fout.close();
[code]....
and second problem is that when i use FileInputStream to read file rahul.txt so it did not read .
View Replies
View Related
May 25, 2015
Need to know how i can store a value in File which is in Properties?
Here I am placing my Properties code :
ReportHTML C:/bea/user_projects/domains/OICDomain/applications/IIMS/IIMS/target/source/REPORT_HTML_DUMP/
ReportEXCEL C:/bea/user_projects/domains/OICDomain/applications/IIMS/IIMS/target/source/REPORT_EXCEL_DUMP/
My Java File :
File destHtmlFolder = new File("C:/bea/user_projects/domains/OICDomain/DOC_SERVER/REPORT_HTML_DUMP");
File srcExcelFolder = new File("C:/bea/user_projects/domains/OICDomain/applications/IIMS/IIMS/target/source/REPORT_EXCEL_DUMP");
View Replies
View Related
Jul 21, 2014
I am using JPF controllers. Already, i am loading a properties file in the controller
(using annotations @Jpf.Controller(messageBundles = { @Jpf.Message Bundle(bundlePath = "validation.validator.Messages") },).
I have a problem. Depending on one of the request variables, i need to load different properties files. All these property files have same keys, but with different messages. I need to take the user to different sites(though internally, the backend logic remains same...Look and feel of the front end along with messages to be shown change to make the users feel they are being directed to a different site).
I am thinking of loading the properties file from the JSP when the user logs in first time from login page so that these properties are available until the session expires & not read the properties file in Controller.
View Replies
View Related
Jan 31, 2011
In my java app there is a code which reads the properties file from src/main/resources folder.
Java Code:
@Component("mailerProperties")
public class MailerProperties {
private static Properties properties;
public MailerProperties() {
properties = new Properties();
[Code] ....
Now I need to create a jar file and also remove the properties file from src/main/resources folder and place it outside the jar file(in the same location as jar file) so that data inside it can be changed easily in future.
Question: Currently it uses ClassPathResource("mailer.properties") to read the prop file. What change I need to make to read it from outside the jar file...
View Replies
View Related
Aug 26, 2014
The code for my button is below - I know it is wrong and that I need to change line 8 at least,so I am technically asking the property object if there is a key_name there but I dont quite get how to do that
//code for button
JButton btnSearch = new JButton("Search");
btnSearch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//find selected command
String key_name = textFieldSearch.getText();
[Code] ....
I basically just want the user typed in word to be checked against a keyword in a properties file and if it exists, pull the key and the value back into a panel
View Replies
View Related
Jan 22, 2014
I have `country.properties` file which have values as follows:
1=USA
91=India
20=Egypt
358=Finland
33=France
679=Fiji
and, have a response class file, which is setting a response from database to display it on `JSP` file. The value that I am getting from database is in the form of `code` or `integer`. I needed to have that value from the database and before setting the response I need to use `getProperty(code)` and save the String representation of that code into a new list and then pass that list to `setResponse`. For e.g: This is the value I am getting from database:
col1 | col2 | col3 |
1 helo done
I needed to show on my JSP page as:
col1 | col2 | col3 |
USA helo done
I was following this tutorial [URL].... but not able to exactly understand how to achieve the same.
This is my `DAOImpl` where I needed to `iterate` and save the `mapped key-value` in a new list and then pass to `JSP` page
public class CountDAOImpl implements IDataDAO {
private Connection conn = null;
private Statement statement = null;
private ResultSet rs = null;
private List<String> country_code = new LinkedList<String>();
[Code] ....
View Replies
View Related
Aug 26, 2014
The code for my button is below - I know it is wrong and that I need to change line 8 at least,so I am technically asking the property object if there is a key_name there but I dont quite get how to do that
//code for button
JButton btnSearch = new JButton("Search");
btnSearch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//find selected command
String key_name = textFieldSearch.getText();
[Code] ....
I basically just want the user typed in word to be checked against a keyword in a proeprties file and if it exists, pull the key and the value back into a panel ....
View Replies
View Related
Feb 4, 2015
I'm currently working on a java project simply to learn java. So far, it creates a window and makes a properties file, or appends data to it if it already exists. The problem is that I'm not quite sure how to check if the file already exists to append data to it. I'm currently using a boolean (configCreated) that appends data when true, and creates a file when false. The problem is that this boolean is always false since it's at the beginning.
Java Code:
package Setup;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Properties;
[code]...
View Replies
View Related
Mar 26, 2014
Whenever I am running applet using appletviewer I am getting the below warning message:
Can't read Appletviewer properties file.
How to correct this?
View Replies
View Related
Dec 19, 2013
When we have a property in the jnlp file that has accented characters (i.e. Mañana), the System.getProperty() call is returning null. This is working fine with Java 7 Update 40, and accented characters in the <information> section of the jnlp file are working fine under Java 7 Update 45, but not in the <resources> section.
Here is an example:
<property name="jnlp.title" value="Mañana"/>
System.getProperty("jnlp.title") returns null
Is there a workaround?
View Replies
View Related
Nov 27, 2014
I need to write the exact directory path like C:LisaestUpdate to a properties file.
I am trying it by
FileInputStream in = new FileInputStream(test.properties);
Properties props = new Properties();
props.load(in);
in.close();
FileOutputStream out = new FileOutputStream(newprop.properties);
props.setProperty("myDirectory","C:Lisa estUpdate" );
props.store(out, null);
out.close();
but the properties file is updated as C:Lisa estUpdate
Extra comes before :.
How can I remove that.
Even I tried it with an command but got same output.
View Replies
View Related
Aug 26, 2014
I have a properties file with key values in it, now when I use my search box to search for a key in the properties file to check whether or not it is there - I can't get it to check and return the key value if it is theere. I've tried a few methods but keep getting a null pointer exception when it hits line 15 in the code all the time so I'm stumped at the minute.
My text field is called textFieldSearch
This is my button code
JButton btnSearch = new JButton("Search");
btnSearch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//search button
//find selected comman
String key_name = textFieldSearch.getText();
[Code] ....
This is my method code
public void FindSelectedKey()
{
if(textFieldSearch != null)
{
properties.getProperty(key_name == textFieldSearch)
}
}
View Replies
View Related
Nov 7, 2014
i have two applications running in Glassfish 2, both are using log4j and they have separated log.propeties. The problem is all the log in App2 always store in App1's log file.Here is how i init to load log.properties file.
try {
Properties p = new Properties();
p.load(new FileInputStream("C:log.properties1"));
org.apache.log4j.PropertyConfigurator.configure(p) ;
} catch(Exception e) {
e.printStackTrace();
}
What does PropertyConfigurator do?
View Replies
View Related
Sep 25, 2014
I have a file called statecapitals.txt that is read in, I want to store it in either a 2d array or hashmap and select a random state then Ask the user for the name of the capital. Then I want to Let them know if they are correct or not and have a choice to play as many times as they like. When they no longer want to play,I want to let them know how many they got correct and how many incorrect. I am not sure which would be better a hash map or 2d array and dont know where to start with each.
here is what the text file looks like:
Alabama - Montgomery
Alaska - Juneau
Arizona - Phoenix
Arkansas - Little Rock
California - Sacramento
Colorado - Denver
[code]....
View Replies
View Related
May 25, 2014
i have to read a file and then store that file in an arraylist. i have 2 clasees, a pyramid and a cylinder class and the file contains unorganized shapes. i want to store all of them in the array but my code does not return anything
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
[Code].....
View Replies
View Related
Nov 30, 2014
I want to store sql query in tree format in xml file.I wrote a code which split the code into different tokens and store it in xml file.I am storing keywords like "select",from,where etc as xmlelements and the values of these keywords as textnodes inside corresponding elements.When the query contains single single statement it works as i need.but when nested query occurs i want to store the nested query inside "where" element.In that case the code didn't works properly.I am hereby attaching the code. When i try to store the xmldata in "CreateFiles.xml" file ,the file is not displaying in the corresponding folder.what is the reason for that?
CreateXml.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package querywork;
import java.io.File;
import java.io.StringReader;
import java.io.StringWriter;
[Code]...
View Replies
View Related
Apr 13, 2015
Now I have a problem for file handling it is not store bytes in to rahul.txt. it stores character not bytes.
package com.fileh;
import java .io.*;
//import java.io.File;
public class Writedata {
public static void main(String args[])
{
try{
FileOutputStream fout= new FileOutputStream("rahul.txt");
String s="my name is rahul";
byte[] b =s.getBytes();
fout.write(b);
fout.close();
}
catch(IOException ioe)
{
}
}
}
View Replies
View Related
Feb 11, 2014
So I am trying to open a file and store the contents into a two dimensional array. I seem to have no problem using this same basic code to read the file and output it. But when I try to change it so that all the data is stored into the array, it does not work.
Java Code:
public void convertFile()
{
String filePath = ("C:UsersBradDownloadsFB1.csv");
String [][] rowCol = new String [429][6];
try
{
BufferedReader br = new BufferedReader(new FileReader(filePath));
StringTokenizer st = null;
System.out.println("Your file is being converted to an array. This may take several minutes.");
[code]....
View Replies
View Related
Sep 25, 2014
I want to read this csv file and store contents on column basis; as date (single array) for all dates. open, high, low and close and be able to manipulate individual elements of the array such as Sum += close[i];
public void pratice() throws Exception {
// Create a File instance
BufferedReader br=new BufferedReader(new FileReader("gtk.csv"));
content = new String[1000];
while(content !=null) {
content[++count] = br.readLine();
[Code] .....
the file looks like this
date Open high low close
12-12-2011 15.00 15.40 14.5 15.2
11-12-2011 15.02 15.70 14.9 15.00
10-12-2011 14.70 16.00 14.70 15.02
...
View Replies
View Related
Mar 17, 2015
public class InputFileData {
/**
* @param inputFile a file giving the data for an electronic
* equipment supplier’s product range
* @return an array of product details
* @throws IOException
*/
public static Product [] readProductDataFile(File inputFile)
throws IOException{
// YOUR CODE HERE
}
This code is meant to be used to read a text file and store the data in an array of type Product[]. I know how to read in a text file and have it sort it into an array, but I've never seen code laid out in this fashion before (specifically "public static Product[]", and I'm unsure how to work with "(File inputfile)". I've looked all over the place but can't find any examples of anything like this.
Also, the code given cannot be changed, as it's that code I have to work with.
I still don't understand how to use it as a whole. For example, do I read the file in the main and have this method read that in and output to the Product class? Do I read the file in this method? I can't work out how to make this work when I have to use this method.
View Replies
View Related
Nov 2, 2014
I want to store an image/file into oracle database using jsp.
I have written code to store data when am running in my machine it is working fine, but not working in server throwing an error saying that "The system cannot find the file specified."
I am attaching the code what am written.
View Replies
View Related
May 8, 2014
How i can get the data from a file, for a key that have multiple values without using split method and i want to store that data in an array
file name:"new.txt"[contains below data]
Name=google.com, yahoo.com,facebook.com
Attachment=abc1,abc2,abc3
I am successfully able to do this using following code
Properties props = new Properties();
String configFilePath = (Cjava_confignew.txt);
props.load(new FileReader(configFilePath));
String TestName = props.getProperty(Name);
String test[] = TestName.split(,);
Now i just want to store the values for key "Name" in array without using TestName.split(,); but i am not able to do this.
I have also used .yml file to avoid this but did not succeed, some way to do this
file name test.yml
Name
-google.com
-yahoo.com
-facebook.com
Attachment
-abc1
-abc2
-abc3
i want to store multiple values for single key(Name) within the array
View Replies
View Related
Oct 10, 2014
The point of this program is to read characters from a txt file and store them into a 2D array. After this has been accomplished, the information is to be printed in the same manner it is read from in the txt file.
Here is the code I have so far:
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Main
{
public static void main(String[] args) throws FileNotFoundException
[Code] ....
And this is the error I am receiving when trying to accomplish the goal of the project:
Exception in thread "main" java.lang.NumberFormatException: For input string: "############"
at java.lang.NumberFormatException.forInputString(Unk nown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at Maze.<init>(Maze.java:15)
at Main.main(Main.java:20)
What's going on here and how I can correct this?? The information I am trying to store in a 2D array and then print is this:
############
#.#........#
#.#.######.#
#.#....#...#
#.###.*#.#.#
#...####.#.#
#.#.#..#.#.#
#.#.#.##.#.#
#o#......#.#
View Replies
View Related
Dec 3, 2014
The main method will drive your program by doing the following:
-Create an array to hold all the individual golfers and par scores (type is Golfer[ ]).
-Prompt the user for a data file containing the Par scores and the player names and score. The format of the input file should look like
Par, 3, 4, 4, 3, 4, 3, 5, 3, 4
George, 3, 3, 4, 3, 4, 2, 3, 3, 4
Paul, 4, 5, 4, 3, 6, 3, 4, 3, 5
Ringo, 3, 3, 4, 3, 4, 2, 4, 3, 4
John, 4, 4, 4, 3, 4, 2, 5, 3, 4
Your program should read the file contents and store the information in your array of Golfers.
View Replies
View Related