fixed-width

What's the best way of parsing a fixed-width formatted file in Java?

非 Y 不嫁゛ 提交于 2019-11-26 12:27:45
问题 I\'ve got a file from a vendor that has 115 fixed-width fields per line. What\'s the best way of parsing that file into the 115 fields so I can use them in my code? My first thought is just to make constants for each field like NAME_START_POSITION and NAME_LENGTH and using substring . That just seems ugly so I\'m curious if there\'s any other recommended ways of doing this. None of the couple of libraries a Google search turned up seemed any better either. Thanks 回答1: I would use a flat file

How to make an inline-block element fill the remainder of the line?

扶醉桌前 提交于 2019-11-26 07:54:04
问题 Is such a thing possible using CSS and two inline-block (or whatever) DIV tags instead of using a table? The table version is this (borders added so you can see it): <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> <html xmlns=\"http://www.w3.org/1999/xhtml\"> <head></head> <body> <table style=\"width:100%;\"> <tr> <td style=\"border:1px solid black;width:100px;height:10px;\"></td> <td style=\"border:1px solid black

Resize UIImage by keeping Aspect ratio and width

醉酒当歌 提交于 2019-11-26 05:49:48
I seen in many posts for resizing the image by keeping aspect ratio. These functions uses the fixed points(Width and Height) for RECT while resizing. But in my project, I need to resize the view based on the Width alone, Height should be taken automatically based on the aspect ratio. anyone help me to achieve this. The method of Srikar works very well, if you know both height and width of your new Size. If you for example know only the width you want to scale to and don't care about the height you first have to calculate the scale factor of the height. +(UIImage*)imageWithImage: (UIImage*)

Using calc() with tables

拥有回忆 提交于 2019-11-26 04:56:57
问题 I\'m trying to get a table with fixed-width td s and variable-width td s. Im using the CSS calc() function, but somehow it seems like I can\'t use % in tables. So that is what I have so far: <table border=\"0\" style=\"width:100%;border-collapse:collapse;\"> <tr style=\"width:100%\"> <td style=\"width:30px;\">1</td> <!--Fixed width--> <td style=\"width: calc( (100% - 230px) / 100 * 40);\">Title</td> <!--Width should be 40% of the remaining space--> <td style=\"width: calc( (100% - 230px) /

Read fixed width record from text file

不羁岁月 提交于 2019-11-26 04:50:37
问题 I\'ve got a text file full of records where each field in each record is a fixed width. My first approach would be to parse each record simply using string.Substring(). Is there a better way? For example, the format could be described as: <Field1(8)><Field2(16)><Field3(12)> And an example file with two records could look like: SomeData0000000000123456SomeMoreData Data2 0000000000555555MoreData I just want to make sure I\'m not overlooking a more elegant way than Substring(). Update: I

Resize UIImage by keeping Aspect ratio and width

心已入冬 提交于 2019-11-26 03:26:11
问题 I seen in many posts for resizing the image by keeping aspect ratio. These functions uses the fixed points(Width and Height) for RECT while resizing. But in my project, I need to resize the view based on the Width alone, Height should be taken automatically based on the aspect ratio. anyone help me to achieve this. 回答1: The method of Srikar works very well, if you know both height and width of your new Size. If you for example know only the width you want to scale to and don't care about the

Read fixed width text file

99封情书 提交于 2019-11-26 00:28:26
问题 I\'m trying to load this ugly-formatted data-set into my R session: http://www.cpc.ncep.noaa.gov/data/indices/wksst8110.for Weekly SST data starts week centered on 3Jan1990 Nino1+2 Nino3 Nino34 Nino4 Week SST SSTA SST SSTA SST SSTA SST SSTA 03JAN1990 23.4-0.4 25.1-0.3 26.6 0.0 28.6 0.3 10JAN1990 23.4-0.8 25.2-0.3 26.6 0.1 28.6 0.3 17JAN1990 24.2-0.3 25.3-0.3 26.5-0.1 28.6 0.3 So far, i can read the lines with x = readLines(path) But the file mixes \'white space\' with \'-\' as separators, and