Results 1 to 3 of 3
- 07-02-2010, 12:18 PM #1
Member
- Join Date
- Jul 2010
- Posts
- 2
- Rep Power
- 0
Formatting java command line output - Multi line string
Is it possible to format output of a string across multiple lines. Writting a script in java that's going to output information to the user in the command line (Max width 80 characters). Some of my strings are longer that 80 character and want to display them accross multiple lines. Won't be using a db. bad example below, sorry!!!
Java Code:Name Age Address Active ____ ___ ______ _____ John 24 No .1 The Yes house, the World Paul 26 unknown No
Is this format possible with printf formatter?
thanks in advance..
- 07-02-2010, 01:21 PM #2
Yes, I think it is. Have you tried it?
You will have to break the String up and insert leading spaces for the continued lines
- 07-02-2010, 02:20 PM #3
Member
- Join Date
- Jul 2010
- Posts
- 2
- Rep Power
- 0
Got the first part (converting to multiple lines), working on the second now
Java Code:private List<String> SplitIntoLines(String convertToLines) { List<String> convertedToLines = new ArrayList<String>(); char[] charArray = convertToLines.toCharArray(); int start = 0; // start with for (int i = 20; i < charArray.length; i++) { if (charArray[i] == ' ') { convertedToLines.add(convertToLines.substring(start, i)); start = i+1; i += 20; } } convertedToLines.add(convertToLines.substring(start)); return convertedToLines; }
Similar Threads
-
Command line interface in Java
By simmi in forum New To JavaReplies: 1Last Post: 03-17-2010, 07:07 AM -
java command line arguments
By Vipul03 in forum New To JavaReplies: 1Last Post: 02-22-2010, 02:00 PM -
Multi Valued Command Line arguments
By joey86 in forum Advanced JavaReplies: 9Last Post: 01-08-2010, 12:07 AM -
Java command line
By agouzoul in forum New To JavaReplies: 2Last Post: 04-02-2008, 12:12 PM -
Unable to execute command line command in java
By LordSM in forum New To JavaReplies: 1Last Post: 08-08-2007, 12:23 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks