How Would You Handle Carridge Returns & Line Feeds in A Spreadsheet file.
I have susessfully created a logging program which creates a spreadsheet file. I have additional information added after the loggging data is complete which I have seperated it by a CR/LF. How can I display this particular part of the file only?
I have attached the file in question, "DATA15.dat".
Attachments:
DATA15.dat 1 KB
Read the file like you normally do (2 D array (from Spread sheet file) )
Then scan the first column for the CR/LF character and find the index of it (may want to use serach 1D array for the collumn).
Then Divide the array into 2 diffrenet arrays, 1 above the found index (containg data to display), and the other one to ignore, or simply use "array subset" function
Similar Messages
-
How do we remove Carriage Return (line feed) inserted in FCC files
Hi Experts,
The file that we generate has a carriage return at the end.
Is there any way in which we can remove this carriage return (line feed) from the file?
The FCC parameters used at our end are as below:
structure.filedNames:
structure.fieldFixedLengths:
structure.fixedLengthTooShortHandling: Cut
Kindly tell us a solution ASAP.
Thanks & Regards
DhwaniDear All,
Let me elaborate on my query
Consider that the files output looks like below:
12 34 45 545 5454 UL
23 33 43 434 4545 FG
45 44 44 586 6535 GM
Now there is an extra line(Carriage Return) getting inserted after the last line 45 44 44 586 6535 GM which is not required at our end.
The cursor of the file instead of stopping on the last character M, points to the next line.
Can you please suggest how to remove this extra line from the files.
I dont understan how will remove context help in this case.
Regards
Dhwani -
How would you read in each line of data and display them to message box?
How would you read in each line of data from the _.txt file_ and display the whole data using an information-type message box?
I know how to display each line of the .txt file data, but I do not know how to display the whole thing.
Here is how I did to display each line of data using the message box:
import javax.swing.JOptionPane; // Needed for the JOptionPane class
import java.io.*; // Needed for file classes
public class problem3
public static void main(String[] args) throws IOException
String filename; // Needed to read the file
String categories; // Needed to read the categories
// Get the filename.
filename = JOptionPane.showInputDialog("Enter the filname.");
// Open the file.
FileReader freader = new FileReader(filename);
BufferedReader inputFile = new BufferedReader(freader);
// Read the categories from the file.
categories = inputFile.readLine();
// If a category was read, display it and
// read the remainig categories.
while(categories != null)
// Display the last category read.
JOptionPane.showMessageDialog(categories);
// Read the next category.
categories = inputFile.readLine();
// Close the file.
inputFile.close();
}I think I need to change here:
// If a category was read, display it and
// read the remainig categories.
while(categories != null)
// Display the last category read.
JOptionPane.showMessageDialog(categories);
// Read the next category.
categories = inputFile.readLine();
}but I don't know how to.
Could you please help me?
Thank you.kyorochan wrote:
jverd wrote:
What is not understood about your question is which part of "read a bunch of lines and display them in a textbox" do you not understand.
First thing's first though: You do recognize that "read a bunch of lines and display them in a textbox" has a few distinct and completely independent parts, right?I'm sorry. I'm not good at English, so I do not understand what you said...
What I was trying to say is "How to display the whole lines of .txt file in single dialog box."We know that.
Do you understand that any problem can be broken down into smaller pieces?
Do you understand that your problem has the following pieces?
1. Read lines from the file.
2. Put the lines together into one String.
3. Put the String into the message box.
and maybe
4. Make sure the message box contents are split into lines exactly as the file was.
(You didn't make it clear if that last one is a requirement.)
Do you understand that 1-4 are completely independent problems and can be solved separately from each other?
Do you understand that you have stated that you already know how to do 1 and 3?
Therefore, you are NOT asking "How to display the whole lines of .txt file in single dialog box." Rather, you ARE asking either #2 or #4 or both.
If you say once more "display all the lines of the file in one dialog box," then it is clear that we are unable to communicate with you and we cannot help you. -
How to insert a carriage return/line feed in a TextEdit without using wrap
Hi,
The string that I want to pass to the textedit is
"Order Notes : bla bla bla
Shipping notes : bla bla bla"
The length of Order notes and shipping notes can vary.
I am using wrapping. But I need to insert a line feed just before Shipping Notes so it comes on a different line inside the textedit box.
How do I achieve this?
Thanks in advance,
SachinGood thinking, Craig
I didn't think of this large textarea being present there, just waiting for a question like this ...
To sum it up for the lazy ones (cause looking at the examples is always worth it, so go do as Craig told ya g!):
CONCATENATE
`Order Notes : bla bla bla`
`Shipping notes : bla bla bla`
INTO text SEPARATED BY cl_abap_char_utilities=>cr_lf. -
How to insert a Carriage Return + Line Feed inside a TextView UI element ?
Hello All,
Does anyone know how can I achieve the above scenario ? I have a string variable that collects and appeneds text messages from various BAPI calls. At the end of the process, the contents of this variable will be mapped to a textview. Problem is, the length of the string collected is way too long and hence not very readable. I am not able to find a way to introduce a CRLF after each message is read and appended. Can anyone advise ? Thank you.
from
Kwok WeiHi Renjith,
So far I manage to get find a walk-around to the problem by using the TextEdit as what you have suggested. This works fine... till when you try to print it out. As you see, during printing, I need to remove the vertical scrollbar and ensure that all the text are properly displayed and I do not see any visibleFooter = false option (similar to that of a table) available to the TextEdit.
If anyone has any suggestions or a more feasible walk around that allows me to print the entire contents in the TextEdit, that will be greatly appreciated
from
Kwok Wei -
How would you pass more than 255 args?
I have an SFTP program that currently is only passed a single file. I am modifying it so that it will loop though an array of files to simulate an mput command. Originally I was just going to call the program with each file to be transferred as an argument but noticed the 255 argument limit. I am looking at potentially having 1500 - 2000 files to transfer at one time. I am just looking for advice on how this should be designed. One idea that was forwarded to me was to just create a listing of the files on the server and use that list file as my argument. Would this be the best approach for this issue?
sdhalepaska wrote:
georgemc wrote:
sdhalepaska wrote:
georgemc wrote:
sdhalepaska wrote:
georgemc wrote:
I see no reason why you need an argument for every file.I would not necessarily need one for every file. Prior to our needing to use this for multiple files, it was easy enough to pass in one file as an argument. That is my question, how would you try to pass in a long list of files?Let's establish what you are concerned about. The 255 argument limit is on method signatures. From what you're saying here, you're talking about arguments being passed into your application from, say, the shell. Am I right?Correct, please see my clarified post. From what I have tested, the 255 argument limit appears to exist even for arguments passed to main.Ah, but arguments passed to main from the command line are passed into main as a single array of Strings, no matter how many of them there are. I have no idea what the limit on those is, but an array can hold millions of elements. I expect your shell will moan about that many, though.
As I see it, you have a few choices. Unless these files are all in different, arbitrary directories, you can specify a list of directories for your app to search. Or you can pass them all in one at a time, and see how you go. Or you can list them in a text file, pass that to your app and have it work them out. Or write a script that invokes your app multiple times. What you don't need, is a method that takes each file as an argument.Thank you for walking me through this. Would you mind telling me which way you would lean if you were designing this? The files will all be in a single directory on the server and I would not like to invoke the app multiple times as it creates a connection during each invocation. They're all in the single directory. Ok, are all the files in that directory to be transferred? If so, I'd just pass the directory name to the app, and have it iterate over all the files. If it's only to be certain ones, how do you know which ones? Is there some regex or filtering you can do on the command line?
If you are interested, the 255 argument limit for main that I tested was from this article:
[http://www.javaspecialists.eu/archive/Issue059.html|http://www.javaspecialists.eu/archive/Issue059.html]
It does die at 255 using Java 1.5.Like I said, arguments to a method are thus limited. But the args passed to an app are passed to main as one argument - an array. In short, that article is not relevant to your problem. -
How would you realize a "blinking"-Effect
The question narrows down to : Which is the best solution to trigger each 0,5 seconds an event (on the JavaFX thread) ?
I could do this with a TimelineAnimation or with a Task<Void>, the problem withthe Task is that I have to update the UI with Platform.runLater() each time which is an impact on the overall perfomance. On the otherhand the TimerLineAnimation is useful to update a property and I do not think that it is the approriate method to realize a blink effect.
How would you do this ?
E.G. I have a circle. This shape is supposed to change its Color every 0,5 seconds (And there can be many of this circles..)I would use some kind of Transition, not because of any performance consideration but merely because it will keep your code cleaner. Used properly, a Task with Platform.runLater(...) to update the UI will be as efficient as anything else, but it can be a bit tricky to get it right (and using Transitions, you delegate the job of getting the code right to the JavaFX team, who are probably better at this kind of thing than either you or I).
The Timeline will actually animate the transition between property values. Almost anything you want to do can be expressed as a change in property; your example of changing the color of a Circle simply involves changing the value of the fillProperty. So using a Timeline will fade one color into another.
If you want a "traditional" blink, you could two PauseTransitions with the onFinished event set to change the color.
This compares the two approaches:
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.PauseTransition;
import javafx.animation.SequentialTransition;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
import javafx.util.Duration;
public class BlinkingCircles extends Application {
@Override
public void start(Stage primaryStage) {
final HBox root = new HBox();
final Group faders = new Group();
final Color blue = new Color(0, 0, 1.0, 0.3);
final Color red = new Color(1.0, 0, 0, 0.3);
final ObjectProperty<Paint> colorFader = new SimpleObjectProperty<Paint>(blue);
for (int i=0; i<20; i++) {
faders.getChildren().add(createCircle(colorFader));
KeyValue blueKV = new KeyValue(colorFader, blue);
KeyValue redKV = new KeyValue(colorFader, red);
KeyFrame blueKF = new KeyFrame(new Duration(1000), blueKV);
KeyFrame redKF = new KeyFrame(new Duration(500), redKV);
Timeline fadeTimeline = new Timeline(redKF, blueKF);
fadeTimeline.setCycleCount(Animation.INDEFINITE);
fadeTimeline.play();
final Group blinkers = new Group();
final ObjectProperty<Paint> colorBlinker = new SimpleObjectProperty<Paint>(blue);
for (int i=0; i<20; i++) {
blinkers.getChildren().add(createCircle(colorBlinker));
PauseTransition changeToRed = createPauseTransition(colorBlinker, red);
PauseTransition changeToBlue = createPauseTransition(colorBlinker, blue);
SequentialTransition blinkTransition = new SequentialTransition(changeToRed, changeToBlue);
blinkTransition.setCycleCount(Animation.INDEFINITE);
blinkTransition.play();
root.getChildren().addAll(faders, blinkers);
Scene scene = new Scene(root, 640, 400);
primaryStage.setScene(scene);
primaryStage.show();
private Circle createCircle(ObjectProperty<Paint> color) {
Circle c = new Circle(Math.random()*300, Math.random()*300, 20);
c.fillProperty().bind(color);
c.setStroke(Color.BLACK);
return c ;
private PauseTransition createPauseTransition(final ObjectProperty<Paint> colorBlinker, final Color color) {
PauseTransition changeColor = new PauseTransition(new Duration(500));
changeColor.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent evt) {
colorBlinker.set(color);
return changeColor ;
public static void main(String[] args) {
launch(args);
} -
How do I handle NULL returns from prepared statement?
Thanks in advance to all those who respond. As a beginner with Java/JSP/JDBC, I need all the help I can get!
Here's the problem...
I'm using a prepared statement in JSP to query a MySQL database.
If there is a value to return, everything works properly.
If the query returns a NULL (empty set) value, I get the following error:
javax.servlet.ServletException: Before start of result set
Here's the code (no negative comments please...I know I'm violating some conventions! I'll restructure it later. Right now I just need help with handling the NULL case):
<%
Driver DriverAppt = (Driver)Class.forName(MM_test_DRIVER).newInstance();
Connection ConnAppt = DriverManager.getConnection(MM_test_STRING,MM_test_USERNAME,MM_test_PASSWORD);PreparedStatement StatementAppt = ConnAppt.prepareStatement("SELECT lastname FROM appts_pid1 WHERE user_id = " + Recordset1__MMColParam + " AND year = " + yy + " AND month = '" + months[mm] + "' AND date = " + dates[dd] + " AND appttime = '16:15:00'");
ResultSet Appt = StatementAppt.executeQuery();
boolean Appt_isEmpty = !Appt.first();
boolean Appt_hasData = !Appt_isEmpty;
Object Appt_data;
int Appt_numRows = 0;
%>
Thanks for the help!!!I think I have a better handle on what's occurring here. To cut to the heart of the problem, I'm going to give a very simple example that illustrates what type of error handling I need.
HERE'S THE EXAMPLE:
Let's say that I have a database of users. There are only two columns in the database: user_id and lastname. There are only 2 users, user_id "1" has lastname "Jones" and user_id "2" has lastname "Smith".
I built a very simple web interface that let's a user enter a number to see if there's a lastname associated with that record. The user has no way of knowing if the user_id exists or not, so they may or may not enter a valid number.
If the user enters a valid user_id (in this case "1" or "2"), then the correct lastname is displayed. If the user enters an invalid user_id (in this case, anything other than "1" or "2") then I get the same "Before start of result set" error that I'm getting in my real application.
So, the question is: WHERE IN THIS CODE WOULD I HANDLE THE RETURN OF AN EMPTY SET?
The goal here is to have the sentence say "The user's lastname is .", basically returning null. If there has to be a value, then have the last sentence say "The user's lastname is unknown."
If you can solve this simple example, you'll have also solved the problem with my main application!!!! :-)
Here's the example code:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="Connections/example.jsp" %>
<%
String Recordset1__MMColParam = "1";
if (request.getParameter("user_id") !=null) {Recordset1__MMColParam = (String)request.getParameter("user_id");}
%>
<%
Driver DriverRecordset1 = (Driver)Class.forName(MM_example_DRIVER).newInstance();
Connection ConnRecordset1 = DriverManager.getConnection(MM_example_STRING,MM_example_USERNAME,MM_example_PASSWORD);
PreparedStatement StatementRecordset1 = ConnRecordset1.prepareStatement("SELECT * FROM test_table WHERE user_id = " + Recordset1__MMColParam + "");
ResultSet Recordset1 = StatementRecordset1.executeQuery();
boolean Recordset1_isEmpty = !Recordset1.next();
boolean Recordset1_hasData = !Recordset1_isEmpty;
Object Recordset1_data;
int Recordset1_numRows = 0;
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="test.jsp" method="get" enctype="application/x-www-form-urlencoded" name="form1" target="_self">
<p> Submit a user id and a lastname will be displayed.</p>
<p>
<input type="text" name="user_id">
<input type="submit" name="" value="Submit">
</p>
</form>
<p>The User's lastname is <%=(((Recordset1_data = Recordset1.getObject("lastname"))==null || Recordset1.wasNull())?"":Recordset1_data)%>.</p>
</body>
</html>
<%
Recordset1.close();
StatementRecordset1.close();
ConnRecordset1.close();
%>
A huge "THANK YOU!!!!" to all those who've helped me here!!! -
What is escape character for for Carriage Return, Line Feed, Form Feed
Hi
I need to a text file which should have following characters
Carriage Return, Line Feed, Form Feed
How do i insert them in a string
i know "\f" is carriage return,
but what are characters for line feed and form feed
Ashishuncle_alice wrote:
jverd wrote:
remus.dragos wrote:
I forgot that it does not exist in Java. A good thing
from my point of view.Running the following makes my computer beep.
public class Bell {
public static void main(String... args) {
System.out.println("\u0007");
Sure, sending a BEL character to the console rings the bell, but that has nothing to do with Java. Anyway, I think he meant Java doesn't support the \a escape sequence in string and char literals.
>
>
>I forgot that it does not exist in Java. A good thing
from my point of view.
Running the following makes my computer beep.
public class Bell {
public static void main(String... args) {
System.out.println("\u0007");
} Sure, sending a BEL character to the console rings the bell, but that has nothing to do with Java. Anyway, I think he meant Java doesn't support the \a escape sequence in string and char literals.
Ah, I thought he was saying Java doesn't support ringing the bell. -
XI: Remove Carriage Return +Line Feed at end of XML
Hi All,
Scenario
Currently, we have a JMS --> XI --> IDOC scenario. The Sender Service always sends a CRLF (Carriage Return & Line Feed+) without fail at the end of each xml file once this non-sap system finishes its transaction.
Example
<STARTOFXML>
Data------
</ENDOFXML>CR+LF
Question
Is it possible to remove this from XI JMS Sender Adapter? From the receiver Service (JMS) this is possible.
Cheers!
SulaimanWhy do you want to remove this? Does this lead to errors?
Regards
Stefan -
How would you write a "wildcard" in a filefilter?
How would you go about to have a wildcard instead of the "*" in the following filefilter;
File[] files = new File("./resultat/resultat_" + "*" + "_" + index[0]).listFiles (new FileFilter () {
public boolean accept (File file) {
return ! file.isDirectory ();
});All help appriciated
- Karl XIIShouldn't "a*" accept all files that begins with "a" and ends with whatever?No. "*" in regexp is a not a wildcard match. Instead it matches one or more instances of the preceeding
value.
Therefore "a*" will match "a", "aa", "aaa", "aaaa" etc but will not match anything which does not end in
an "a".
The following might help you out. (not the most elegent expression but it will do
import java.util.regex.*;
public class RegExp{
public static void main(String[] args) {
Pattern p = Pattern.compile("a*b");
Matcher m = p.matcher("aaaab");
System.out.println(m.matches());
// interesting bit here
// match one or more occurances of any characters in the ASCII charset (the \\p{ASCII}* bit
p = Pattern.compile("hello_\\p{ASCII}*_b");
m = p.matcher("hello_wibble_b");
System.out.println(m.matches());
} -
How would you change an integer variable per second
Im new to action script, and I'm working on a game were your health variable will add 1 hp automatically every second if the health variable is not equal to 100. How would you do that?
If you are using AS3, you can use the Timer class. You can specify it to activate every second and use an event listener.event handler function to add to the value if it is less than 100.
var healthTimer:Timer = new Timer(1000);
function addHealth(evt.TimerEvent):void {
if(health < 100) health += 1;
healthTimer.addEventListener(TimerEvent.TIMER, addHealth);
healthTimer.start();
If you are using AS2, look into setInterval(). -
How would you change the state to the base state?
How would you change the state to the base state? Its not
letting me do something like:
currentState='<Base State>';Sorry about the vagueness of that last reply :)
What I have done now in my code is this:
viewstack1.addChildAt(loginCanvas,0);
toggle.selectedIndex = 0;
However nothing happens at this line of code:
toggle.selectedIndex = 0;
but this works:
toggle.selectedIndex = 1; or ...
toggle.selectedIndex = 2;
toggle.selectedIndex = 3;
toggle.selectedIndex = 4;
toggle.selectedIndex = 5;
toggle.selectedIndex = 6;
The strange thing is that if I have a button on the screen:
<mx:Button x="10" y="3" label="Button"
click="toggle.selectedIndex =0"/>
and the user clicks it the toggle.selectedIndex = 0; works.
I'm stumped, any ideas? -
How would you implement equals ()
For complex classes with many data members, my dilema is:
1. equals should return true only if all fields of the two objects are
equals.
2. equals should return true if the key(s) of the two objets are equal.
For instance, we have the Class Person, that contains dozens of
data: ID, name, age, job, salary, children, more 1000 items.
Person is like a record in a DB table. There can not be two persons
with the same ID.
In this case, how would you implement equals, and why?
thanksWhat I'm trying to say is: what is equality foryou?
Two objects are equal if all there contents areequals
or is it enough
to compare their keys?
In the latter case, there can happen, by somereason,
that we can end
up with two objects with the same keys, but all the
rest of
the contents different.i think you meant to say that:
In the latter case, there can happen, by somereason,
that we can end
up with two objects with different keys, but
all the rest of the contents the same.and the answer is, and listen carefully, it totally
depends on the application you are writing. there
is no hard definition of equality where custom classes
are concerned... that is the answer.If this question arises, you should revisit your design.
If two entities have equal keys, they should be considered to be equal. Otherwise the attributes you call keys are in the fact normal attributes and no keys. -
How would you optimize the dimensions?
How would you optimize the dimensions?
HI Vsu,
The basic way of optmizing the Dimensions would be to have similar kind of objects into that dimensions. For example having the Customer related infoobjects into the customer dimension will obviously help in optimized data retrieval performance.
There could be some scenarious where U can optimize the Dimension by dividing the Dimension Data into Line Item Dimension. By this way U would divide the load of data onto the Dimension and the cube, hence again optimizing the performance.
Hope this helps U. U can be graceful by assinging points.
Regards,
Syed.
Maybe you are looking for
-
Hi, I just thought I would provide my experience here to both see if others have seen and dealt with the issue - and to alert others that this may be something worth considering in upgrading from Mac OSX 10.9.3 My 27" iMac 11,1 update to 10.9.4 was a
-
How to bring back an email that separated and flew off screen before finished?
I had an email almost completed and the curser didn't move the screen up, so I tried to move the screen up by putting mouse on the bright blue line on the right side of the composed email. What happened was where the curser was pushed all the words u
-
Hi masters can any one tell me the name of the table where condition record P101 for <b>purchase order</b> is maintained ..
-
Calendar Alerts turning on when not originally set
Hi, I'm having an issue where I create a calendar event without an alert however come the event time an alert goes off! This is really annoying when I set an all day event and get woken up by a rogue alert at midnight! It happens on every event I set
-
Saving state (saveState() restoreState())
Before navigating to another page (by navigation rule) I would like to save the state of current page and after returning back restoring the state. I tried everything possible with saveState() and restoreState() on components and it doesn't work. Ple